PluginProbe
CSS & JavaScript Toolbox / 11.5
CSS & JavaScript Toolbox v11.5
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / ServicesFW / EntityModel.class.php

EntityModel.class.php in CSS & JavaScript Toolbox 11.5, at framework/ServicesFW/EntityModel.class.php

66 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 /**
7 *
8 */
9 abstract class CJTServicesEntityModel {
10
11 /**
12 * put your comment there...
13 *
14 * @param mixed $data
15 * @return CJTServicesItemModel
16 */
17 public function __construct($data = null) {
18 # Make sure data is array
19 if( ! $data ) {
20 $data = array();
21 }
22 # Fill with data
23 $this->exchangeArray( $data );
24 }
25
26 /**
27 * put your comment there...
28 *
29 * @param mixed $data
30 */
31 public function exchangeArray($data) {
32 # Fetch properties for all model members
33 foreach ( get_object_vars( $this ) as $name => $value ) {
34 $this->$name = isset( $data[ $name ] ) ? $data[ $name ] : null;
35 }
36 # Chain
37 return $this;
38 }
39
40 /**
41 * put your comment there...
42 *
43 */
44 public function getArray() {
45 # Gett all vars
46 $vars = get_object_vars( $this );
47 # Exclude NULL values
48 foreach ( $vars as $name => $value ) {
49 if ( $value === null ) {
50 unset( $vars[ $name ] );
51 }
52 }
53 return $vars;
54 }
55
56 /**
57 * put your comment there...
58 *
59 * @param CJTServicesEntityModel $model
60 * @return CJTServicesEntityModel
61 */
62 public function isEqual(CJTServicesEntityModel & $model) {
63 return md5( print_r( get_object_vars( $this ), true ) ) == md5( print_r( get_object_vars( $model ), true ) );
64 }
65 }
66