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 | * Whether this property should be serialized. |
||
45 | * |
||
46 | * @var bool |
||
47 | */ |
||
48 | public $serialize = true; |
||
49 | |||
50 | /** |
||
51 | * Determines whether this propety is stored in search. |
||
52 | * |
||
53 | * @var bool |
||
54 | */ |
||
55 | public $searchProperty = false; |
||
56 | |||
57 | /** |
||
58 | * Constructor. |
||
59 | * |
||
60 | * @param string $key |
||
61 | * @param bool $mixin |
||
62 | */ |
||
63 | public function __construct($key, $mixin = false) |
||
69 | |||
70 | /** |
||
71 | * Enables or disables saving of this property. |
||
72 | * |
||
73 | * @param bool $bit |
||
74 | * @return self |
||
75 | */ |
||
76 | public function enableSave($bit = true) |
||
81 | |||
82 | /** |
||
83 | * Enables or disables serialization of this property. |
||
84 | * |
||
85 | * @param bool $bit |
||
86 | * @return self |
||
87 | */ |
||
88 | public function enableSerialize($bit = true) |
||
93 | |||
94 | /** |
||
95 | * Gets the field key. |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getKey() |
||
103 | |||
104 | /** |
||
105 | * Determines whether this propety is stored in search. |
||
106 | * |
||
107 | * @return bool |
||
108 | */ |
||
109 | public function isSearchProperty() |
||
113 | |||
114 | /** |
||
115 | * Sets whether this property is stored in search. |
||
116 | * |
||
117 | * @param bool $bit |
||
118 | * @return self |
||
119 | */ |
||
120 | public function setSearchProperty($bit = true) |
||
125 | |||
126 | /** |
||
127 | * Whether this property should be saved/persisted to the data layer. |
||
128 | * |
||
129 | * @return bool |
||
130 | */ |
||
131 | public function shouldSave() |
||
135 | |||
136 | /** |
||
137 | * Whether this property should be serialized. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function shouldSerialize() |
||
145 | |||
146 | /** |
||
147 | * Validates that the field key is not reserved. |
||
148 | * |
||
149 | * @param string $key |
||
150 | * @throws MetadataException |
||
151 | */ |
||
152 | protected function validateKey($key) |
||
159 | } |
||
160 |