1 | <?php namespace Rocket\Entities; |
||
14 | abstract class Entity |
||
15 | { |
||
16 | public static $types; |
||
17 | |||
18 | /** |
||
19 | * The content represented by this entity |
||
20 | * |
||
21 | * @var Content |
||
22 | */ |
||
23 | protected $content; //id, created_at |
||
24 | |||
25 | /** |
||
26 | * The revision represented by this entity |
||
27 | * |
||
28 | * @var Revision |
||
29 | */ |
||
30 | protected $revision; //language_id, updated_at |
||
31 | |||
32 | /** |
||
33 | * The fields in this entity |
||
34 | * |
||
35 | * @var array<FieldCollection> |
||
36 | */ |
||
37 | protected $data; |
||
38 | |||
39 | 39 | public function __construct($data = []) |
|
49 | |||
50 | 39 | protected function initialize(array $fields) |
|
59 | |||
60 | 36 | protected function initializeField($field, $settings) |
|
78 | |||
79 | 33 | protected function hydrate($data) |
|
83 | |||
84 | abstract protected function getFields(); |
||
85 | |||
86 | /** |
||
87 | * Create a new revision based on the same content ID but without the content. |
||
88 | * Very useful if you want to add a new language |
||
89 | * |
||
90 | * @param int $language_id |
||
91 | * @return static |
||
92 | */ |
||
93 | 3 | public function newRevision($language_id = null) |
|
104 | |||
105 | /** |
||
106 | * Check if the field is related to the content |
||
107 | * |
||
108 | * @param string $field |
||
109 | * @return bool |
||
110 | */ |
||
111 | 36 | protected function isContentField($field) |
|
115 | |||
116 | /** |
||
117 | * Check if the field exists on the entity |
||
118 | * |
||
119 | * @param string $field |
||
120 | * @return bool |
||
121 | */ |
||
122 | 24 | public function hasField($field) |
|
126 | |||
127 | /** |
||
128 | * @param string $field |
||
129 | * @return FieldCollection |
||
130 | */ |
||
131 | 18 | public function getField($field) |
|
135 | |||
136 | /** |
||
137 | * Check if the field is related to the revision |
||
138 | * |
||
139 | * @param string $field |
||
140 | * @return bool |
||
141 | */ |
||
142 | 33 | protected function isRevisionField($field) |
|
146 | |||
147 | /** |
||
148 | * Dynamically retrieve attributes on the model. |
||
149 | * |
||
150 | * @param string $key |
||
151 | * @throws RuntimeException |
||
152 | * @return $this|bool|\Carbon\Carbon|\DateTime|mixed|static |
||
153 | */ |
||
154 | 24 | public function __get($key) |
|
170 | |||
171 | /** |
||
172 | * Dynamically set attributes on the model. |
||
173 | * |
||
174 | * @param string $key |
||
175 | * @param mixed $value |
||
176 | * @throws RuntimeException |
||
177 | */ |
||
178 | 18 | public function __set($key, $value) |
|
206 | |||
207 | /** |
||
208 | * Convert the Entity to an array. |
||
209 | * |
||
210 | * @return array |
||
211 | */ |
||
212 | public function toArray() |
||
225 | } |
||
226 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.