1 | <?php namespace core\src; |
||
5 | class UrlParser |
||
6 | { |
||
|
|||
7 | |||
8 | const SEPARATOR = '/'; |
||
9 | |||
10 | const VALUE_SEPARATOR = '-or-'; |
||
11 | |||
12 | const PREFIX_BRAND = 'brand-'; |
||
13 | |||
14 | const PREFIX_PROPERTY = 'property-'; |
||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private $properties = []; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $brands = []; |
||
25 | |||
26 | /** |
||
27 | * Only filter segments |
||
28 | * @var array |
||
29 | */ |
||
30 | private $filterSegments; |
||
31 | |||
32 | /** |
||
33 | * Url segments without filter |
||
34 | * @var array |
||
35 | */ |
||
36 | private $urlSegments; |
||
37 | |||
38 | /** |
||
39 | * All segments |
||
40 | * @var array |
||
41 | */ |
||
42 | private $segments = []; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | private $locale; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | private $url; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $fullUrl; |
||
58 | |||
59 | /** |
||
60 | * @var CoreConfiguration |
||
61 | */ |
||
62 | private $coreConfiguration; |
||
63 | |||
64 | /** |
||
65 | * @var int |
||
66 | */ |
||
67 | private $brandSegmentPosition = 0; |
||
68 | |||
69 | /** |
||
70 | * @var array |
||
71 | */ |
||
72 | private $propertySegmentPositions = []; |
||
73 | |||
74 | /** |
||
75 | * @var string |
||
76 | */ |
||
77 | private $paramsString; |
||
78 | |||
79 | public function __construct(CoreConfiguration $coreConfiguration) { |
||
83 | |||
84 | /** |
||
85 | * @param $url |
||
86 | */ |
||
87 | public function parse($url) { |
||
98 | |||
99 | public function getFullUrl($locale = true, $filterSegments = true, $getParams = true) { |
||
119 | |||
120 | /** |
||
121 | * Url without locale and filter parameters |
||
122 | * @return string |
||
123 | */ |
||
124 | public function getUrl() { |
||
127 | |||
128 | /** |
||
129 | * Locale from url |
||
130 | * @return string |
||
131 | */ |
||
132 | public function getLocale() { |
||
135 | |||
136 | /** |
||
137 | * @return array |
||
138 | */ |
||
139 | public function getFilterSegments() { |
||
142 | |||
143 | /** |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getFilterSegment() { |
||
149 | |||
150 | /** |
||
151 | * @return array |
||
152 | */ |
||
153 | public function getProperties() { |
||
156 | |||
157 | /** |
||
158 | * @return array |
||
159 | */ |
||
160 | public function getBrands() { |
||
163 | |||
164 | /** |
||
165 | * @param $propertyName |
||
166 | * @return array|null |
||
167 | */ |
||
168 | public function getValues($propertyName) { |
||
171 | |||
172 | /** |
||
173 | * @return string csv_name |
||
174 | */ |
||
175 | public function getFirstProperty() { |
||
178 | |||
179 | /** |
||
180 | * @param string $property |
||
181 | * @return string value |
||
182 | */ |
||
183 | public function getFirstValue($property) { |
||
187 | |||
188 | /** |
||
189 | * @return int |
||
190 | */ |
||
191 | public function countBrands() { |
||
194 | |||
195 | /** |
||
196 | * @return int |
||
197 | */ |
||
198 | public function countProperties() { |
||
201 | |||
202 | /** |
||
203 | * @param $propertyName |
||
204 | * @return int |
||
205 | */ |
||
206 | public function countValues($propertyName) { |
||
209 | |||
210 | /** |
||
211 | * Explode url segments and check denied |
||
212 | * @return array |
||
213 | * @throws PageNotFoundException |
||
214 | */ |
||
215 | private function createSegments() { |
||
219 | |||
220 | /** |
||
221 | * @return string|null |
||
222 | */ |
||
223 | private function detectLanguage() { |
||
231 | |||
232 | public function brandSegmentIsFirst() { |
||
238 | |||
239 | /** |
||
240 | * @param $segments |
||
241 | * @return array|null |
||
242 | */ |
||
243 | private function fetchFilterSegments($segments) { |
||
264 | |||
265 | /** |
||
266 | * @param array $segment |
||
267 | */ |
||
268 | private function fetchBrands($segment) { |
||
272 | |||
273 | /** |
||
274 | * @param array $segment |
||
275 | */ |
||
276 | private function fetchProperties($segment) { |
||
290 | |||
291 | /** |
||
292 | * @return string |
||
293 | */ |
||
294 | private function fetchUrl() { |
||
306 | } |