1 | <?php |
||
22 | abstract class AbstractDefinition implements NodeDefinitionInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $name; |
||
28 | |||
29 | /** |
||
30 | * @var mixed |
||
31 | */ |
||
32 | protected $defaultValue; |
||
33 | |||
34 | /** |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $defaultValueSet = false; |
||
38 | |||
39 | /** |
||
40 | * @var bool |
||
41 | */ |
||
42 | protected $required = false; |
||
43 | |||
44 | /** |
||
45 | * @var mixed |
||
46 | */ |
||
47 | protected $nullEquivalent; |
||
48 | |||
49 | /** |
||
50 | * @var DefinitionInterface|NodeDefinitionInterface|NodeInterface|null |
||
51 | */ |
||
52 | protected $parent; |
||
53 | |||
54 | /** |
||
55 | * @var bool |
||
56 | */ |
||
57 | protected $allowOverwrite = true; |
||
58 | |||
59 | /** |
||
60 | * Constructor. |
||
61 | * |
||
62 | * @param string $name |
||
63 | * @param NodeDefinitionInterface|null $parent |
||
64 | */ |
||
65 | public function __construct($name, NodeDefinitionInterface $parent = null) |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | public function setName($name) |
||
78 | |||
79 | /** |
||
80 | * Get node name. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getName() |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | public function setParent($parent = null) |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | * |
||
109 | * @return NodeInterface|NodeDefinitionBuilder|DefinitionInterface|NodeDefinitionContainerInterface|null |
||
110 | */ |
||
111 | public function end() |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public function cannotBeOverwritten() |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function defaultValue($value) |
||
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | public function defaultNull() |
||
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | public function defaultTrue() |
||
154 | |||
155 | /** |
||
156 | * {@inheritdoc} |
||
157 | */ |
||
158 | public function defaultFalse() |
||
162 | |||
163 | /** |
||
164 | * {@inheritdoc} |
||
165 | */ |
||
166 | public function isRequired() |
||
172 | |||
173 | /** |
||
174 | * {@inheritdoc} |
||
175 | */ |
||
176 | public function getNode() |
||
180 | |||
181 | /** |
||
182 | * Assert that correct node parent. |
||
183 | */ |
||
184 | protected function assertParentNode() |
||
193 | |||
194 | /** |
||
195 | * Create and configure node by definition. |
||
196 | * |
||
197 | * @return NodeInterface|PrototypeNodeInterface |
||
198 | */ |
||
199 | abstract protected function createNode(); |
||
200 | |||
201 | /** |
||
202 | * Check if parent is valid instance. |
||
203 | * |
||
204 | * @param mixed $parent |
||
205 | * |
||
206 | * @return bool |
||
207 | */ |
||
208 | private function isValidParentInstance($parent) |
||
214 | } |
||
215 |