1 | <?php |
||
16 | abstract class NavigationItemConfig implements Config |
||
17 | { |
||
18 | const OPTION_CLASS = 'class'; |
||
19 | const OPTION_LABEL = 'label'; |
||
20 | const OPTION_IDENTIFIER = 'identifier'; |
||
21 | const OPTION_CHILDREN = 'children'; |
||
22 | const OPTION_MATCHES = 'matches'; |
||
23 | |||
24 | /** @var OptionsResolver */ |
||
25 | protected $resolver; |
||
26 | /** @var array */ |
||
27 | protected $supportedClasses = []; |
||
28 | |||
29 | public function __construct() |
||
53 | |||
54 | /** |
||
55 | * @param Item $item |
||
56 | * @param ItemFactory $factory |
||
57 | * @return array |
||
58 | */ |
||
59 | public function toArray(Item $item, ItemFactory $factory): array |
||
72 | |||
73 | /** |
||
74 | * @param array $config |
||
75 | * @param ItemFactory $factory |
||
76 | * @return Item |
||
77 | * @throws NavigationItemClassDoesNotExistException |
||
78 | */ |
||
79 | public function toObject(array $config, ItemFactory $factory): Item |
||
100 | |||
101 | /** |
||
102 | * @param array $config |
||
103 | * @return array |
||
104 | */ |
||
105 | protected function resolve(array $config): array |
||
109 | |||
110 | /** |
||
111 | * @param string $class |
||
112 | */ |
||
113 | protected function checkIfSupport(string $class) |
||
119 | |||
120 | /** |
||
121 | * Specifies how the object should be created |
||
122 | * |
||
123 | * @param string $className |
||
124 | * @param array $arguments |
||
125 | * @return Item |
||
126 | */ |
||
127 | abstract protected function getObject(string $className, array $arguments); |
||
128 | |||
129 | /** |
||
130 | * Specifies how should object be transformed to an array |
||
131 | * |
||
132 | * @param Item $item |
||
133 | * @return array |
||
134 | */ |
||
135 | abstract protected function getArray($item): array; |
||
136 | |||
137 | /** |
||
138 | * Specifies additional options |
||
139 | * This method is called after initial OptionsResolver setup |
||
140 | * Use OptionsResolver within this method |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | abstract protected function config(); |
||
145 | |||
146 | /** |
||
147 | * @param array $config |
||
148 | * @return string |
||
149 | */ |
||
150 | private function popClassName(array $config): string |
||
157 | |||
158 | private function addManualMatchesToArray(array $result, Item $item) |
||
164 | |||
165 | private function addManualMatchesToObject(Item $object, array $config) |
||
171 | } |
||
172 |