PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / classes / log-item.php

log-item.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/classes/log-item.php

67 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace StoreEngine\Classes;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 class LogItem extends AbstractEntity {
9 protected string $table = 'storeengine_logs';
10 protected string $primary_key = 'id';
11 protected string $object_type = 'log';
12
13 protected array $data =[
14 'date' => '',
15 'module' => '',
16 'title' => '',
17 'status' => '',
18 'content' => '',
19 ];
20
21 protected array $data_format =[
22 'date' => '%s',
23 'module' => '%s',
24 'title' => '%s',
25 'status' => '%s',
26 'content' => '%s',
27 ];
28
29 public function __construct( $read = 0 ) {
30 parent::__construct( 0 );
31
32 if ( is_array( $read ) || is_object( $read ) ) {
33 $this->set_object_read( false );
34 $this->set_props( (array) $read );
35 $this->set_object_read( true );
36 } elseif ( is_numeric( $read ) && $read > 0 ) {
37 $this->set_id( $read );
38 $this->read();
39 }
40 }
41
42 // api response
43 public function get_data(): array {
44 $data = parent::get_data();
45
46 return array_merge( $data,[
47 'id' => $this->get_id(),
48 'date' => $this->get_formatted_date_prop( 'date', 'mysql' )
49 ] );
50 }
51
52 // Getters
53 public function get_date( $context = 'view' ) {
54 return $this->get_formatted_date_prop( 'date', 'mysql', false, $context );
55 }
56 public function get_module( $context = 'view' ) { return $this->get_prop('module', $context); }
57 public function get_title( $context = 'view' ) { return $this->get_prop('title', $context); }
58 public function get_status( string $context = 'view' ): ?string { return $this->get_prop('status', $context); }
59 public function get_content( $context = 'view' ) { return $this->get_prop('content', $context); }
60
61 // Setters
62 public function set_date( $value ) { $this->set_prop('date', $value); }
63 public function set_module( $value ) { $this->set_prop('module', $value); }
64 public function set_title( $value ) { $this->set_prop('title', $value); }
65 public function set_status( $value ) { $this->set_prop('status', $value); }
66 public function set_content( $value ) { $this->set_prop('content', $value); }
67 }