1 | <?php |
||
54 | class SystemProperties extends AbstractProperties |
||
55 | { |
||
56 | /** |
||
57 | * Collection name |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | const COLLECTION = 'system'; |
||
62 | /** |
||
63 | * ID property |
||
64 | * |
||
65 | * @var string |
||
66 | */ |
||
67 | const PROPERTY_ID = 'id'; |
||
68 | /** |
||
69 | * Type property |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | const PROPERTY_TYPE = 'type'; |
||
74 | /** |
||
75 | * Revision property |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | const PROPERTY_REVISION = 'revision'; |
||
80 | /** |
||
81 | * Created property |
||
82 | * |
||
83 | * @var string |
||
84 | */ |
||
85 | const PROPERTY_CREATED = 'created'; |
||
86 | /** |
||
87 | * Published property |
||
88 | * |
||
89 | * @var string |
||
90 | */ |
||
91 | const PROPERTY_PUBLISHED = 'published'; |
||
92 | /** |
||
93 | * Hash property |
||
94 | * |
||
95 | * @var string |
||
96 | */ |
||
97 | const PROPERTY_HASH = 'hash'; |
||
98 | /** |
||
99 | * Object ID |
||
100 | * |
||
101 | * @var Id |
||
102 | */ |
||
103 | protected $id = null; |
||
104 | /** |
||
105 | * Object type |
||
106 | * |
||
107 | * @var Type |
||
108 | */ |
||
109 | protected $type = null; |
||
110 | /** |
||
111 | * Object revision |
||
112 | * |
||
113 | * @var Revision |
||
114 | */ |
||
115 | protected $revision = null; |
||
116 | /** |
||
117 | * Creation date |
||
118 | * |
||
119 | * @var \DateTimeImmutable |
||
120 | */ |
||
121 | protected $created = null; |
||
122 | /** |
||
123 | * Publication date |
||
124 | * |
||
125 | * @var \DateTimeImmutable |
||
126 | */ |
||
127 | protected $published = null; |
||
128 | /** |
||
129 | * Object hash |
||
130 | * |
||
131 | * @var string |
||
132 | */ |
||
133 | protected $hash = ''; |
||
134 | |||
135 | /******************************************************************************* |
||
136 | * PUBLIC METHODS |
||
137 | *******************************************************************************/ |
||
138 | |||
139 | /** |
||
140 | * System properties constructor |
||
141 | * |
||
142 | * @param array $data Property data |
||
143 | * @param ObjectInterface $object Owner object |
||
144 | */ |
||
145 | 5 | public function __construct(array $data, ObjectInterface $object) |
|
190 | |||
191 | /** |
||
192 | * Return the object ID |
||
193 | * |
||
194 | * @return Id Object ID |
||
195 | */ |
||
196 | 1 | public function getId() |
|
200 | |||
201 | /** |
||
202 | * Return the object type |
||
203 | * |
||
204 | * @return Type Object type |
||
205 | */ |
||
206 | 1 | public function getType() |
|
210 | |||
211 | /** |
||
212 | * Return the object revision |
||
213 | * |
||
214 | * @return Revision Object revision |
||
215 | */ |
||
216 | 1 | public function getRevision() |
|
220 | |||
221 | /** |
||
222 | * Return the creation date & time |
||
223 | * |
||
224 | * @return \DateTimeImmutable Creation date & time |
||
225 | */ |
||
226 | 1 | public function getCreated() |
|
230 | |||
231 | /** |
||
232 | * Return the publication date & time |
||
233 | * |
||
234 | * @return \DateTimeImmutable Publication date & time |
||
235 | */ |
||
236 | 1 | public function getPublished() |
|
240 | |||
241 | /** |
||
242 | * Return the object hash |
||
243 | * |
||
244 | * @return string Object hash |
||
245 | */ |
||
246 | public function getHash() |
||
250 | |||
251 | /** |
||
252 | * Indicate that the object now got published |
||
253 | * |
||
254 | * @return SystemProperties System properties |
||
255 | * @throws RuntimeException If the object is already published |
||
256 | */ |
||
257 | 1 | public function publish() |
|
269 | |||
270 | /** |
||
271 | * Return the property values as array |
||
272 | * |
||
273 | * @return array Property values |
||
274 | */ |
||
275 | 1 | public function toArray() |
|
286 | |||
287 | /******************************************************************************* |
||
288 | * PRIVATE METHODS |
||
289 | *******************************************************************************/ |
||
290 | |||
291 | /** |
||
292 | * Test if the object hash is a valid sha1 value |
||
293 | * |
||
294 | * @return bool The object hash is a valid sha1 value |
||
295 | */ |
||
296 | 3 | protected function hasValidHash() |
|
300 | } |
||
301 |