1 | <?php |
||
50 | class SystemProperties extends AbstractProperties |
||
51 | { |
||
52 | /** |
||
53 | * Object ID |
||
54 | * |
||
55 | * @var Id |
||
56 | */ |
||
57 | protected $_id = 0; |
||
58 | |||
59 | /** |
||
60 | * Object type |
||
61 | * |
||
62 | * @var Type |
||
63 | */ |
||
64 | protected $_type = null; |
||
65 | |||
66 | /** |
||
67 | * Object revision |
||
68 | * |
||
69 | * @var Revision |
||
70 | */ |
||
71 | protected $_revision = null; |
||
72 | |||
73 | /** |
||
74 | * Creation date |
||
75 | * |
||
76 | * @var \DateTimeImmutable |
||
77 | */ |
||
78 | protected $_created = null; |
||
79 | |||
80 | /** |
||
81 | * Publication date |
||
82 | * |
||
83 | * @var \DateTimeImmutable |
||
84 | */ |
||
85 | protected $_published = null; |
||
86 | |||
87 | /** |
||
88 | * Object hash |
||
89 | * |
||
90 | * @var string |
||
91 | */ |
||
92 | protected $_hash = null; |
||
93 | |||
94 | /** |
||
95 | * Collection name |
||
96 | * |
||
97 | * @var string |
||
98 | */ |
||
99 | const COLLECTION = 'system'; |
||
100 | |||
101 | /******************************************************************************* |
||
102 | * PUBLIC METHODS |
||
103 | *******************************************************************************/ |
||
104 | |||
105 | /** |
||
106 | * System properties constructor |
||
107 | * |
||
108 | * @param array $data Property data |
||
109 | * @param ObjectInterface $object Owner object |
||
110 | */ |
||
111 | 3 | public function __construct(array $data, ObjectInterface $object) |
|
112 | { |
||
113 | 3 | parent::__construct($data, $object); |
|
114 | |||
115 | // Initialize the object ID |
||
116 | 3 | if (array_key_exists('id', $data)) { |
|
117 | 2 | $this->_setId(Id::unserialize($data['id'])); |
|
118 | 2 | } |
|
119 | |||
120 | // Initialize the object type |
||
121 | 3 | if (array_key_exists('type', $data)) { |
|
122 | 3 | $this->_setType(Type::unserialize($data['type'])); |
|
123 | 2 | } |
|
124 | |||
125 | // Initialize the object revision |
||
126 | 2 | if (array_key_exists('revision', $data)) { |
|
127 | 2 | $this->_setRevision(Revision::unserialize($data['revision'])); |
|
128 | 2 | } |
|
129 | |||
130 | // Initialize the object creation date |
||
131 | 2 | if (array_key_exists('created', $data)) { |
|
132 | 1 | $this->_setCreated(new \DateTimeImmutable('@'.$data['created'])); |
|
133 | 1 | } |
|
134 | |||
135 | // Initialize the object publication date |
||
136 | 2 | if (array_key_exists('published', $data)) { |
|
137 | 2 | $this->_setPublished(new \DateTimeImmutable('@'.$data['published'])); |
|
138 | 2 | } |
|
139 | |||
140 | // Initialize the object hash |
||
141 | 2 | if (array_key_exists('hash', $data)) { |
|
142 | $this->_setHash($data['hash']); |
||
143 | } |
||
144 | 2 | } |
|
145 | |||
146 | /** |
||
147 | * Return the object ID |
||
148 | * |
||
149 | * @return Id Object ID |
||
150 | */ |
||
151 | 1 | public function getId() |
|
152 | { |
||
153 | 1 | return $this->_id; |
|
154 | } |
||
155 | |||
156 | /** |
||
157 | * Return the object type |
||
158 | * |
||
159 | * @return Type Object type |
||
160 | */ |
||
161 | 1 | public function getType() |
|
162 | { |
||
163 | 1 | return $this->_type; |
|
164 | } |
||
165 | |||
166 | /** |
||
167 | * Return the object revision |
||
168 | * |
||
169 | * @return Revision Object revision |
||
170 | */ |
||
171 | 1 | public function getRevision() |
|
172 | { |
||
173 | 1 | return $this->_revision; |
|
174 | } |
||
175 | |||
176 | /** |
||
177 | * Return the creation date & time |
||
178 | * |
||
179 | * @return \DateTimeImmutable Creation date & time |
||
180 | */ |
||
181 | 1 | public function getCreated() |
|
182 | { |
||
183 | 1 | return $this->_created; |
|
184 | } |
||
185 | |||
186 | /** |
||
187 | * Return the publication date & time |
||
188 | * |
||
189 | * @return \DateTimeImmutable Publication date & time |
||
190 | */ |
||
191 | 1 | public function getPublished() |
|
192 | { |
||
193 | 1 | return $this->_published; |
|
194 | } |
||
195 | |||
196 | /** |
||
197 | * Return the object hash |
||
198 | * |
||
199 | * @return string Object hash |
||
200 | */ |
||
201 | public function getHash() |
||
205 | |||
206 | /******************************************************************************* |
||
207 | * PRIVATE METHODS |
||
208 | *******************************************************************************/ |
||
209 | |||
210 | /** |
||
211 | * Set the object ID |
||
212 | * |
||
213 | * @param Id $id |
||
214 | */ |
||
215 | 2 | protected function _setId(Id $id) |
|
219 | |||
220 | /** |
||
221 | * Set the object type |
||
222 | * |
||
223 | * @param Type $type Object type |
||
224 | */ |
||
225 | 2 | protected function _setType(Type $type) |
|
229 | |||
230 | /** |
||
231 | * Set the object revision |
||
232 | * |
||
233 | * @param Revision $revision Object revision |
||
234 | */ |
||
235 | 2 | protected function _setRevision(Revision $revision) |
|
239 | |||
240 | /** |
||
241 | * Set the publication date & time |
||
242 | * |
||
243 | * @param \DateTimeImmutable $published Publication date & time |
||
244 | */ |
||
245 | 2 | protected function _setPublished(\DateTimeImmutable $published) |
|
249 | |||
250 | /** |
||
251 | * Set the creation date & time |
||
252 | * |
||
253 | * @param \DateTimeImmutable $published Creation date & time |
||
254 | */ |
||
255 | 1 | protected function _setCreated(\DateTimeImmutable $created) |
|
256 | { |
||
257 | 1 | $this->_created = $created; |
|
258 | 1 | } |
|
259 | |||
260 | /** |
||
261 | * Set the object hash |
||
262 | * |
||
263 | * @param string $hash Object hash |
||
264 | */ |
||
265 | protected function _setHash($hash) |
||
269 | } |
||
270 |