1 | <?php |
||
13 | abstract class FieldMetadata |
||
14 | { |
||
15 | /** |
||
16 | * A friendly description of the field. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | public $description; |
||
21 | |||
22 | /** |
||
23 | * The field key. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | public $key; |
||
28 | |||
29 | /** |
||
30 | * Determines if this field came from a mixin. |
||
31 | * |
||
32 | * @var bool |
||
33 | */ |
||
34 | public $mixin; |
||
35 | |||
36 | /** |
||
37 | * Whether this property should be persisted. |
||
38 | * |
||
39 | * @var bool |
||
40 | */ |
||
41 | public $save = true; |
||
42 | |||
43 | /** |
||
44 | * Determines whether this propety is stored in search. |
||
45 | * |
||
46 | * @var bool |
||
47 | */ |
||
48 | public $searchProperty = false; |
||
49 | |||
50 | /** |
||
51 | * Constructor. |
||
52 | * |
||
53 | * @param string $key |
||
54 | * @param bool $mixin |
||
55 | */ |
||
56 | public function __construct($key, $mixin = false) |
||
62 | |||
63 | /** |
||
64 | * Enables or disables saving of this property. |
||
65 | * |
||
66 | * @param bool $bit |
||
67 | * @return self |
||
68 | */ |
||
69 | public function enableSave($bit = true) |
||
74 | |||
75 | /** |
||
76 | * Gets the field key. |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getKey() |
||
84 | |||
85 | /** |
||
86 | * Determines whether this propety is stored in search. |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | public function isSearchProperty() |
||
94 | |||
95 | /** |
||
96 | * Sets whether this property is stored in search. |
||
97 | * |
||
98 | * @param bool $bit |
||
99 | * @return self |
||
100 | */ |
||
101 | public function setSearchProperty($bit = true) |
||
106 | |||
107 | /** |
||
108 | * Whether this property should be saved/persisted to the data layer. |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function shouldSave() |
||
116 | |||
117 | /** |
||
118 | * Validates that the field key is not reserved. |
||
119 | * |
||
120 | * @param string $key |
||
121 | * @throws MetadataException |
||
122 | */ |
||
123 | protected function validateKey($key) |
||
130 | } |
||
131 |