2011-04-05 11:30:59 +01:00
|
|
|
<?php
|
|
|
|
|
2011-05-17 09:11:27 +01:00
|
|
|
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
2011-05-17 15:51:56 +01:00
|
|
|
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
2011-04-20 12:54:39 +01:00
|
|
|
use Symfony\Component\Routing\RequestContext;
|
2011-04-05 11:30:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ProjectUrlMatcher
|
|
|
|
*
|
|
|
|
* This class has been auto-generated
|
|
|
|
* by the Symfony Routing Component.
|
|
|
|
*/
|
|
|
|
class ProjectUrlMatcher extends Symfony\Tests\Component\Routing\Fixtures\RedirectableUrlMatcher
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
2011-04-20 21:49:56 +01:00
|
|
|
public function __construct(RequestContext $context)
|
2011-04-05 11:30:59 +01:00
|
|
|
{
|
|
|
|
$this->context = $context;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function match($pathinfo)
|
|
|
|
{
|
|
|
|
$allow = array();
|
2011-06-29 02:01:08 +01:00
|
|
|
$pathinfo = urldecode($pathinfo);
|
2011-04-05 11:30:59 +01:00
|
|
|
|
|
|
|
// foo
|
|
|
|
if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#x', $pathinfo, $matches)) {
|
|
|
|
return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// bar
|
2011-05-03 13:48:08 +01:00
|
|
|
if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
|
2011-06-04 17:59:57 +01:00
|
|
|
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
|
|
|
|
$allow = array_merge($allow, array('GET', 'HEAD'));
|
2011-04-05 11:30:59 +01:00
|
|
|
goto not_bar;
|
|
|
|
}
|
|
|
|
$matches['_route'] = 'bar';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
not_bar:
|
|
|
|
|
2011-06-04 11:28:01 +01:00
|
|
|
// barhead
|
|
|
|
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
|
2011-06-04 17:59:57 +01:00
|
|
|
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
|
|
|
|
$allow = array_merge($allow, array('GET', 'HEAD'));
|
2011-06-04 11:28:01 +01:00
|
|
|
goto not_barhead;
|
|
|
|
}
|
|
|
|
$matches['_route'] = 'barhead';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
not_barhead:
|
|
|
|
|
2011-04-05 11:30:59 +01:00
|
|
|
// baz
|
|
|
|
if ($pathinfo === '/test/baz') {
|
|
|
|
return array('_route' => 'baz');
|
|
|
|
}
|
|
|
|
|
|
|
|
// baz2
|
|
|
|
if ($pathinfo === '/test/baz.html') {
|
|
|
|
return array('_route' => 'baz2');
|
|
|
|
}
|
|
|
|
|
|
|
|
// baz3
|
|
|
|
if (rtrim($pathinfo, '/') === '/test/baz3') {
|
|
|
|
if (substr($pathinfo, -1) !== '/') {
|
|
|
|
return $this->redirect($pathinfo.'/', 'baz3');
|
|
|
|
}
|
|
|
|
return array('_route' => 'baz3');
|
|
|
|
}
|
|
|
|
|
|
|
|
// baz4
|
2011-05-03 13:48:08 +01:00
|
|
|
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/?$#x', $pathinfo, $matches)) {
|
2011-04-05 11:30:59 +01:00
|
|
|
if (substr($pathinfo, -1) !== '/') {
|
|
|
|
return $this->redirect($pathinfo.'/', 'baz4');
|
|
|
|
}
|
|
|
|
$matches['_route'] = 'baz4';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
// baz5
|
2011-05-03 13:48:08 +01:00
|
|
|
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/?$#x', $pathinfo, $matches)) {
|
2011-06-04 17:59:57 +01:00
|
|
|
if ($this->context->getMethod() != 'POST') {
|
|
|
|
$allow[] = 'POST';
|
2011-04-05 11:30:59 +01:00
|
|
|
goto not_baz5;
|
|
|
|
}
|
|
|
|
if (substr($pathinfo, -1) !== '/') {
|
|
|
|
return $this->redirect($pathinfo.'/', 'baz5');
|
|
|
|
}
|
|
|
|
$matches['_route'] = 'baz5';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
not_baz5:
|
|
|
|
|
|
|
|
// baz.baz6
|
2011-05-03 13:48:08 +01:00
|
|
|
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/?$#x', $pathinfo, $matches)) {
|
2011-06-04 17:59:57 +01:00
|
|
|
if ($this->context->getMethod() != 'PUT') {
|
|
|
|
$allow[] = 'PUT';
|
2011-04-05 11:30:59 +01:00
|
|
|
goto not_bazbaz6;
|
|
|
|
}
|
|
|
|
if (substr($pathinfo, -1) !== '/') {
|
|
|
|
return $this->redirect($pathinfo.'/', 'baz.baz6');
|
|
|
|
}
|
|
|
|
$matches['_route'] = 'baz.baz6';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
not_bazbaz6:
|
|
|
|
|
|
|
|
// foofoo
|
|
|
|
if ($pathinfo === '/foofoo') {
|
|
|
|
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
|
|
|
}
|
|
|
|
|
2011-06-29 02:23:30 +01:00
|
|
|
// quoter
|
|
|
|
if (preg_match('#^/(?P<quoter>[\']+)$#x', $pathinfo, $matches)) {
|
|
|
|
$matches['_route'] = 'quoter';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
|
2011-05-04 22:29:47 +01:00
|
|
|
if (0 === strpos($pathinfo, '/a')) {
|
2011-06-29 02:23:30 +01:00
|
|
|
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
2011-05-04 22:29:47 +01:00
|
|
|
// foo
|
2011-06-29 02:23:30 +01:00
|
|
|
if (preg_match('#^/a/b\'b/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
|
2011-05-04 22:29:47 +01:00
|
|
|
$matches['_route'] = 'foo';
|
|
|
|
return $matches;
|
|
|
|
}
|
2011-06-29 02:01:08 +01:00
|
|
|
|
2011-05-04 22:29:47 +01:00
|
|
|
// bar
|
2011-06-29 02:23:30 +01:00
|
|
|
if (preg_match('#^/a/b\'b/(?P<bar>[^/]+?)$#x', $pathinfo, $matches)) {
|
2011-05-04 22:29:47 +01:00
|
|
|
$matches['_route'] = 'bar';
|
|
|
|
return $matches;
|
|
|
|
}
|
2011-06-29 02:01:08 +01:00
|
|
|
|
2011-06-15 08:36:36 +01:00
|
|
|
// foo1
|
2011-06-29 02:23:30 +01:00
|
|
|
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]+?)$#x', $pathinfo, $matches)) {
|
2011-06-15 08:36:36 +01:00
|
|
|
$matches['_route'] = 'foo1';
|
|
|
|
return $matches;
|
|
|
|
}
|
2011-06-29 02:01:08 +01:00
|
|
|
|
2011-06-15 08:36:36 +01:00
|
|
|
// bar1
|
2011-06-29 02:23:30 +01:00
|
|
|
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]+?)$#x', $pathinfo, $matches)) {
|
2011-06-15 08:36:36 +01:00
|
|
|
$matches['_route'] = 'bar1';
|
|
|
|
return $matches;
|
|
|
|
}
|
2011-06-29 02:01:08 +01:00
|
|
|
|
2011-05-04 22:29:47 +01:00
|
|
|
}
|
2011-06-29 02:01:08 +01:00
|
|
|
|
2011-06-15 08:22:10 +01:00
|
|
|
// ababa
|
|
|
|
if ($pathinfo === '/ababa') {
|
|
|
|
return array('_route' => 'ababa');
|
|
|
|
}
|
2011-06-29 02:01:08 +01:00
|
|
|
|
2011-06-15 08:22:10 +01:00
|
|
|
// foo
|
|
|
|
if (preg_match('#^/aba/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
|
|
|
|
$matches['_route'] = 'foo';
|
|
|
|
return $matches;
|
|
|
|
}
|
2011-06-29 02:01:08 +01:00
|
|
|
|
2011-05-04 22:29:47 +01:00
|
|
|
}
|
|
|
|
|
2011-06-04 18:44:04 +01:00
|
|
|
// foo
|
|
|
|
if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
|
|
|
|
$matches['_route'] = 'foo';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
// bar
|
|
|
|
if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<bar>[^/]+?)$#x', $pathinfo, $matches)) {
|
|
|
|
$matches['_route'] = 'bar';
|
|
|
|
return $matches;
|
|
|
|
}
|
|
|
|
|
2011-04-19 23:25:45 +01:00
|
|
|
// secure
|
|
|
|
if ($pathinfo === '/secure') {
|
2011-04-20 12:54:39 +01:00
|
|
|
if ($this->context->getScheme() !== 'https') {
|
2011-04-19 23:25:45 +01:00
|
|
|
return $this->redirect($pathinfo, 'secure', 'https');
|
|
|
|
}
|
|
|
|
return array('_route' => 'secure');
|
|
|
|
}
|
|
|
|
|
|
|
|
// nonsecure
|
|
|
|
if ($pathinfo === '/nonsecure') {
|
2011-04-20 12:54:39 +01:00
|
|
|
if ($this->context->getScheme() !== 'http') {
|
2011-04-19 23:25:45 +01:00
|
|
|
return $this->redirect($pathinfo, 'nonsecure', 'http');
|
|
|
|
}
|
|
|
|
return array('_route' => 'nonsecure');
|
|
|
|
}
|
|
|
|
|
2011-05-17 15:51:56 +01:00
|
|
|
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
2011-04-05 11:30:59 +01:00
|
|
|
}
|
|
|
|
}
|