]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / routing / Symfony / Component / Routing / Tests / Fixtures / dumper / url_matcher2.php
1 <?php
2
3 use Symfony\Component\Routing\Exception\MethodNotAllowedException;
4 use Symfony\Component\Routing\Exception\ResourceNotFoundException;
5 use Symfony\Component\Routing\RequestContext;
6
7 /**
8 * ProjectUrlMatcher
9 *
10 * This class has been auto-generated
11 * by the Symfony Routing Component.
12 */
13 class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
14 {
15 /**
16 * Constructor.
17 */
18 public function __construct(RequestContext $context)
19 {
20 $this->context = $context;
21 }
22
23 public function match($pathinfo)
24 {
25 $allow = array();
26 $pathinfo = rawurldecode($pathinfo);
27
28 // foo
29 if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
30 return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
31 }
32
33 if (0 === strpos($pathinfo, '/bar')) {
34 // bar
35 if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
36 if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
37 $allow = array_merge($allow, array('GET', 'HEAD'));
38 goto not_bar;
39 }
40
41 return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
42 }
43 not_bar:
44
45 // barhead
46 if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
47 if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
48 $allow = array_merge($allow, array('GET', 'HEAD'));
49 goto not_barhead;
50 }
51
52 return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
53 }
54 not_barhead:
55
56 }
57
58 if (0 === strpos($pathinfo, '/test')) {
59 if (0 === strpos($pathinfo, '/test/baz')) {
60 // baz
61 if ($pathinfo === '/test/baz') {
62 return array('_route' => 'baz');
63 }
64
65 // baz2
66 if ($pathinfo === '/test/baz.html') {
67 return array('_route' => 'baz2');
68 }
69
70 // baz3
71 if (rtrim($pathinfo, '/') === '/test/baz3') {
72 if (substr($pathinfo, -1) !== '/') {
73 return $this->redirect($pathinfo.'/', 'baz3');
74 }
75
76 return array('_route' => 'baz3');
77 }
78
79 }
80
81 // baz4
82 if (preg_match('#^/test/(?P<foo>[^/]++)/?$#s', $pathinfo, $matches)) {
83 if (substr($pathinfo, -1) !== '/') {
84 return $this->redirect($pathinfo.'/', 'baz4');
85 }
86
87 return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
88 }
89
90 // baz5
91 if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
92 if ($this->context->getMethod() != 'POST') {
93 $allow[] = 'POST';
94 goto not_baz5;
95 }
96
97 return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
98 }
99 not_baz5:
100
101 // baz.baz6
102 if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
103 if ($this->context->getMethod() != 'PUT') {
104 $allow[] = 'PUT';
105 goto not_bazbaz6;
106 }
107
108 return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
109 }
110 not_bazbaz6:
111
112 }
113
114 // foofoo
115 if ($pathinfo === '/foofoo') {
116 return array ( 'def' => 'test', '_route' => 'foofoo',);
117 }
118
119 // quoter
120 if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
121 return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
122 }
123
124 // space
125 if ($pathinfo === '/spa ce') {
126 return array('_route' => 'space');
127 }
128
129 if (0 === strpos($pathinfo, '/a')) {
130 if (0 === strpos($pathinfo, '/a/b\'b')) {
131 // foo1
132 if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
133 return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ());
134 }
135
136 // bar1
137 if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
138 return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
139 }
140
141 }
142
143 // overridden
144 if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
145 return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ());
146 }
147
148 if (0 === strpos($pathinfo, '/a/b\'b')) {
149 // foo2
150 if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) {
151 return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
152 }
153
154 // bar2
155 if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) {
156 return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
157 }
158
159 }
160
161 }
162
163 if (0 === strpos($pathinfo, '/multi')) {
164 // helloWorld
165 if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
166 return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',));
167 }
168
169 // overridden2
170 if ($pathinfo === '/multi/new') {
171 return array('_route' => 'overridden2');
172 }
173
174 // hey
175 if (rtrim($pathinfo, '/') === '/multi/hey') {
176 if (substr($pathinfo, -1) !== '/') {
177 return $this->redirect($pathinfo.'/', 'hey');
178 }
179
180 return array('_route' => 'hey');
181 }
182
183 }
184
185 // foo3
186 if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
187 return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ());
188 }
189
190 // bar3
191 if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
192 return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
193 }
194
195 if (0 === strpos($pathinfo, '/aba')) {
196 // ababa
197 if ($pathinfo === '/ababa') {
198 return array('_route' => 'ababa');
199 }
200
201 // foo4
202 if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
203 return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
204 }
205
206 }
207
208 $host = $this->context->getHost();
209
210 if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
211 // route1
212 if ($pathinfo === '/route1') {
213 return array('_route' => 'route1');
214 }
215
216 // route2
217 if ($pathinfo === '/c2/route2') {
218 return array('_route' => 'route2');
219 }
220
221 }
222
223 if (preg_match('#^b\\.example\\.com$#s', $host, $hostMatches)) {
224 // route3
225 if ($pathinfo === '/c2/route3') {
226 return array('_route' => 'route3');
227 }
228
229 }
230
231 if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
232 // route4
233 if ($pathinfo === '/route4') {
234 return array('_route' => 'route4');
235 }
236
237 }
238
239 if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
240 // route5
241 if ($pathinfo === '/route5') {
242 return array('_route' => 'route5');
243 }
244
245 }
246
247 // route6
248 if ($pathinfo === '/route6') {
249 return array('_route' => 'route6');
250 }
251
252 if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $host, $hostMatches)) {
253 if (0 === strpos($pathinfo, '/route1')) {
254 // route11
255 if ($pathinfo === '/route11') {
256 return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
257 }
258
259 // route12
260 if ($pathinfo === '/route12') {
261 return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
262 }
263
264 // route13
265 if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
266 return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ());
267 }
268
269 // route14
270 if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
271 return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
272 }
273
274 }
275
276 }
277
278 if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
279 // route15
280 if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
281 return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
282 }
283
284 }
285
286 if (0 === strpos($pathinfo, '/route1')) {
287 // route16
288 if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
289 return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
290 }
291
292 // route17
293 if ($pathinfo === '/route17') {
294 return array('_route' => 'route17');
295 }
296
297 }
298
299 if (0 === strpos($pathinfo, '/a')) {
300 // a
301 if ($pathinfo === '/a/a...') {
302 return array('_route' => 'a');
303 }
304
305 if (0 === strpos($pathinfo, '/a/b')) {
306 // b
307 if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
308 return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ());
309 }
310
311 // c
312 if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
313 return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
314 }
315
316 }
317
318 }
319
320 // secure
321 if ($pathinfo === '/secure') {
322 if ($this->context->getScheme() !== 'https') {
323 return $this->redirect($pathinfo, 'secure', 'https');
324 }
325
326 return array('_route' => 'secure');
327 }
328
329 // nonsecure
330 if ($pathinfo === '/nonsecure') {
331 if ($this->context->getScheme() !== 'http') {
332 return $this->redirect($pathinfo, 'nonsecure', 'http');
333 }
334
335 return array('_route' => 'nonsecure');
336 }
337
338 throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
339 }
340 }