Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
@@ -15,366 +15,270 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
public function match($pathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$allow = $allowSchemes = array();
|
||||
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
|
||||
return $ret;
|
||||
}
|
||||
if ($allow) {
|
||||
throw new MethodNotAllowedException(array_keys($allow));
|
||||
}
|
||||
if (!in_array($this->context->getMethod(), array('HEAD', 'GET'), true)) {
|
||||
// no-op
|
||||
} elseif ($allowSchemes) {
|
||||
redirect_scheme:
|
||||
$scheme = $this->context->getScheme();
|
||||
$this->context->setScheme(key($allowSchemes));
|
||||
try {
|
||||
if ($ret = $this->doMatch($pathinfo)) {
|
||||
return $this->redirect($pathinfo, $ret['_route'], $this->context->getScheme()) + $ret;
|
||||
}
|
||||
} finally {
|
||||
$this->context->setScheme($scheme);
|
||||
}
|
||||
} elseif ('/' !== $pathinfo) {
|
||||
$pathinfo = '/' !== $pathinfo[-1] ? $pathinfo.'/' : substr($pathinfo, 0, -1);
|
||||
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
|
||||
return $this->redirect($pathinfo, $ret['_route']) + $ret;
|
||||
}
|
||||
if ($allowSchemes) {
|
||||
goto redirect_scheme;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
private function doMatch(string $rawPathinfo, array &$allow = array(), array &$allowSchemes = array()): ?array
|
||||
{
|
||||
$allow = $allowSchemes = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$host = strtolower($context->getHost());
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/foo')) {
|
||||
// foo
|
||||
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
|
||||
}
|
||||
switch ($pathinfo) {
|
||||
default:
|
||||
$routes = array(
|
||||
'/test/baz' => array(array('_route' => 'baz'), null, null, null),
|
||||
'/test/baz.html' => array(array('_route' => 'baz2'), null, null, null),
|
||||
'/test/baz3/' => array(array('_route' => 'baz3'), null, null, null),
|
||||
'/foofoo' => array(array('_route' => 'foofoo', 'def' => 'test'), null, null, null),
|
||||
'/spa ce' => array(array('_route' => 'space'), null, null, null),
|
||||
'/multi/new' => array(array('_route' => 'overridden2'), null, null, null),
|
||||
'/multi/hey/' => array(array('_route' => 'hey'), null, null, null),
|
||||
'/ababa' => array(array('_route' => 'ababa'), null, null, null),
|
||||
'/route1' => array(array('_route' => 'route1'), 'a.example.com', null, null),
|
||||
'/c2/route2' => array(array('_route' => 'route2'), 'a.example.com', null, null),
|
||||
'/route4' => array(array('_route' => 'route4'), 'a.example.com', null, null),
|
||||
'/c2/route3' => array(array('_route' => 'route3'), 'b.example.com', null, null),
|
||||
'/route5' => array(array('_route' => 'route5'), 'c.example.com', null, null),
|
||||
'/route6' => array(array('_route' => 'route6'), null, null, null),
|
||||
'/route11' => array(array('_route' => 'route11'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null),
|
||||
'/route12' => array(array('_route' => 'route12', 'var1' => 'val'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null),
|
||||
'/route17' => array(array('_route' => 'route17'), null, null, null),
|
||||
'/secure' => array(array('_route' => 'secure'), null, null, array('https' => 0)),
|
||||
'/nonsecure' => array(array('_route' => 'nonsecure'), null, null, array('http' => 0)),
|
||||
);
|
||||
|
||||
// foofoo
|
||||
if ('/foofoo' === $pathinfo) {
|
||||
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/bar')) {
|
||||
// bar
|
||||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('GET', 'HEAD'));
|
||||
goto not_bar;
|
||||
if (!isset($routes[$pathinfo])) {
|
||||
break;
|
||||
}
|
||||
list($ret, $requiredHost, $requiredMethods, $requiredSchemes) = $routes[$pathinfo];
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_bar:
|
||||
|
||||
// barhead
|
||||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_barhead;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_barhead:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/test')) {
|
||||
if (0 === strpos($pathinfo, '/test/baz')) {
|
||||
// baz
|
||||
if ('/test/baz' === $pathinfo) {
|
||||
return array('_route' => 'baz');
|
||||
}
|
||||
|
||||
// baz2
|
||||
if ('/test/baz.html' === $pathinfo) {
|
||||
return array('_route' => 'baz2');
|
||||
}
|
||||
|
||||
// baz3
|
||||
if ('/test/baz3' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'baz3');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_baz3;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz3'));
|
||||
if ($requiredHost) {
|
||||
if ('#' !== $requiredHost[0] ? $requiredHost !== $host : !preg_match($requiredHost, $host, $hostMatches)) {
|
||||
break;
|
||||
}
|
||||
if ('#' === $requiredHost[0] && $hostMatches) {
|
||||
$hostMatches['_route'] = $ret['_route'];
|
||||
$ret = $this->mergeDefaults($hostMatches, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_baz3:
|
||||
|
||||
}
|
||||
|
||||
// baz4
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_baz4;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz4'));
|
||||
$hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
|
||||
if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
|
||||
if ($hasRequiredScheme) {
|
||||
$allow += $requiredMethods;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!$hasRequiredScheme) {
|
||||
$allowSchemes += $requiredSchemes;
|
||||
break;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_baz4:
|
||||
}
|
||||
|
||||
// baz5
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_baz5;
|
||||
$matchedPathinfo = $host.'.'.$pathinfo;
|
||||
$regexList = array(
|
||||
0 => '{^(?'
|
||||
.'|(?:(?:[^./]*+\\.)++)(?'
|
||||
.'|/foo/(baz|symfony)(*:47)'
|
||||
.'|/bar(?'
|
||||
.'|/([^/]++)(*:70)'
|
||||
.'|head/([^/]++)(*:90)'
|
||||
.')'
|
||||
.'|/test/([^/]++)/(?'
|
||||
.'|(*:116)'
|
||||
.')'
|
||||
.'|/([\']+)(*:132)'
|
||||
.'|/a/(?'
|
||||
.'|b\'b/([^/]++)(?'
|
||||
.'|(*:161)'
|
||||
.'|(*:169)'
|
||||
.')'
|
||||
.'|(.*)(*:182)'
|
||||
.'|b\'b/([^/]++)(?'
|
||||
.'|(*:205)'
|
||||
.'|(*:213)'
|
||||
.')'
|
||||
.')'
|
||||
.'|/multi/hello(?:/([^/]++))?(*:249)'
|
||||
.'|/([^/]++)/b/([^/]++)(?'
|
||||
.'|(*:280)'
|
||||
.'|(*:288)'
|
||||
.')'
|
||||
.'|/aba/([^/]++)(*:310)'
|
||||
.')|(?i:([^\\.]++)\\.example\\.com)\\.(?'
|
||||
.'|/route1(?'
|
||||
.'|3/([^/]++)(*:372)'
|
||||
.'|4/([^/]++)(*:390)'
|
||||
.')'
|
||||
.')|(?i:c\\.example\\.com)\\.(?'
|
||||
.'|/route15/([^/]++)(*:442)'
|
||||
.')|(?:(?:[^./]*+\\.)++)(?'
|
||||
.'|/route16/([^/]++)(*:490)'
|
||||
.'|/a/(?'
|
||||
.'|a\\.\\.\\.(*:511)'
|
||||
.'|b/(?'
|
||||
.'|([^/]++)(*:532)'
|
||||
.'|c/([^/]++)(*:550)'
|
||||
.')'
|
||||
.')'
|
||||
.')'
|
||||
.')$}sD',
|
||||
);
|
||||
|
||||
foreach ($regexList as $offset => $regex) {
|
||||
while (preg_match($regex, $matchedPathinfo, $matches)) {
|
||||
switch ($m = (int) $matches['MARK']) {
|
||||
case 116:
|
||||
$matches = array('foo' => $matches[1] ?? null);
|
||||
|
||||
// baz4
|
||||
return $this->mergeDefaults(array('_route' => 'baz4') + $matches, array());
|
||||
|
||||
// baz5
|
||||
$ret = $this->mergeDefaults(array('_route' => 'baz5') + $matches, array());
|
||||
if (!isset(($a = array('POST' => 0))[$requestMethod])) {
|
||||
$allow += $a;
|
||||
goto not_baz5;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
$ret = $this->mergeDefaults(array('_route' => 'baz.baz6') + $matches, array());
|
||||
if (!isset(($a = array('PUT' => 0))[$requestMethod])) {
|
||||
$allow += $a;
|
||||
goto not_bazbaz6;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
not_bazbaz6:
|
||||
|
||||
break;
|
||||
case 161:
|
||||
$matches = array('foo' => $matches[1] ?? null);
|
||||
|
||||
// foo1
|
||||
$ret = $this->mergeDefaults(array('_route' => 'foo1') + $matches, array());
|
||||
if (!isset(($a = array('PUT' => 0))[$requestMethod])) {
|
||||
$allow += $a;
|
||||
goto not_foo1;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
not_foo1:
|
||||
|
||||
break;
|
||||
case 205:
|
||||
$matches = array('foo1' => $matches[1] ?? null);
|
||||
|
||||
// foo2
|
||||
return $this->mergeDefaults(array('_route' => 'foo2') + $matches, array());
|
||||
|
||||
break;
|
||||
case 280:
|
||||
$matches = array('_locale' => $matches[1] ?? null, 'foo' => $matches[2] ?? null);
|
||||
|
||||
// foo3
|
||||
return $this->mergeDefaults(array('_route' => 'foo3') + $matches, array());
|
||||
|
||||
break;
|
||||
default:
|
||||
$routes = array(
|
||||
47 => array(array('_route' => 'foo', 'def' => 'test'), array('bar'), null, null),
|
||||
70 => array(array('_route' => 'bar'), array('foo'), array('GET' => 0, 'HEAD' => 1), null),
|
||||
90 => array(array('_route' => 'barhead'), array('foo'), array('GET' => 0), null),
|
||||
132 => array(array('_route' => 'quoter'), array('quoter'), null, null),
|
||||
169 => array(array('_route' => 'bar1'), array('bar'), null, null),
|
||||
182 => array(array('_route' => 'overridden'), array('var'), null, null),
|
||||
213 => array(array('_route' => 'bar2'), array('bar1'), null, null),
|
||||
249 => array(array('_route' => 'helloWorld', 'who' => 'World!'), array('who'), null, null),
|
||||
288 => array(array('_route' => 'bar3'), array('_locale', 'bar'), null, null),
|
||||
310 => array(array('_route' => 'foo4'), array('foo'), null, null),
|
||||
372 => array(array('_route' => 'route13'), array('var1', 'name'), null, null),
|
||||
390 => array(array('_route' => 'route14', 'var1' => 'val'), array('var1', 'name'), null, null),
|
||||
442 => array(array('_route' => 'route15'), array('name'), null, null),
|
||||
490 => array(array('_route' => 'route16', 'var1' => 'val'), array('name'), null, null),
|
||||
511 => array(array('_route' => 'a'), array(), null, null),
|
||||
532 => array(array('_route' => 'b'), array('var'), null, null),
|
||||
550 => array(array('_route' => 'c'), array('var'), null, null),
|
||||
);
|
||||
|
||||
list($ret, $vars, $requiredMethods, $requiredSchemes) = $routes[$m];
|
||||
|
||||
foreach ($vars as $i => $v) {
|
||||
if (isset($matches[1 + $i])) {
|
||||
$ret[$v] = $matches[1 + $i];
|
||||
}
|
||||
}
|
||||
|
||||
$hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
|
||||
if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
|
||||
if ($hasRequiredScheme) {
|
||||
$allow += $requiredMethods;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!$hasRequiredScheme) {
|
||||
$allowSchemes += $requiredSchemes;
|
||||
break;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
|
||||
if (!in_array($requestMethod, array('PUT'))) {
|
||||
$allow = array_merge($allow, array('PUT'));
|
||||
goto not_bazbaz6;
|
||||
if (550 === $m) {
|
||||
break;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
$regex = substr_replace($regex, 'F', $m - $offset, 1 + strlen($m));
|
||||
$offset += strlen($m);
|
||||
}
|
||||
not_bazbaz6:
|
||||
|
||||
}
|
||||
|
||||
// quoter
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
|
||||
}
|
||||
|
||||
// space
|
||||
if ('/spa ce' === $pathinfo) {
|
||||
return array('_route' => 'space');
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo1
|
||||
if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ());
|
||||
}
|
||||
|
||||
// bar1
|
||||
if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// overridden
|
||||
if (preg_match('#^/a/(?P<var>.*)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo2
|
||||
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
|
||||
}
|
||||
|
||||
// bar2
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/multi')) {
|
||||
// helloWorld
|
||||
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',));
|
||||
}
|
||||
|
||||
// hey
|
||||
if ('/multi/hey' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'hey');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_hey;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'hey'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_hey:
|
||||
|
||||
// overridden2
|
||||
if ('/multi/new' === $pathinfo) {
|
||||
return array('_route' => 'overridden2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// foo3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ());
|
||||
}
|
||||
|
||||
// bar3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/aba')) {
|
||||
// ababa
|
||||
if ('/ababa' === $pathinfo) {
|
||||
return array('_route' => 'ababa');
|
||||
}
|
||||
|
||||
// foo4
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$host = $context->getHost();
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route1
|
||||
if ('/route1' === $pathinfo) {
|
||||
return array('_route' => 'route1');
|
||||
}
|
||||
|
||||
// route2
|
||||
if ('/c2/route2' === $pathinfo) {
|
||||
return array('_route' => 'route2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route3
|
||||
if ('/c2/route3' === $pathinfo) {
|
||||
return array('_route' => 'route3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route4
|
||||
if ('/route4' === $pathinfo) {
|
||||
return array('_route' => 'route4');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route5
|
||||
if ('/route5' === $pathinfo) {
|
||||
return array('_route' => 'route5');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route6
|
||||
if ('/route6' === $pathinfo) {
|
||||
return array('_route' => 'route6');
|
||||
}
|
||||
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route11
|
||||
if ('/route11' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
|
||||
}
|
||||
|
||||
// route12
|
||||
if ('/route12' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
// route13
|
||||
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ());
|
||||
}
|
||||
|
||||
// route14
|
||||
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route15
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route16
|
||||
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
// route17
|
||||
if ('/route17' === $pathinfo) {
|
||||
return array('_route' => 'route17');
|
||||
}
|
||||
|
||||
// a
|
||||
if ('/a/a...' === $pathinfo) {
|
||||
return array('_route' => 'a');
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b')) {
|
||||
// b
|
||||
if (preg_match('#^/a/b/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ());
|
||||
}
|
||||
|
||||
// c
|
||||
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// secure
|
||||
if ('/secure' === $pathinfo) {
|
||||
$ret = array('_route' => 'secure');
|
||||
$requiredSchemes = array ( 'https' => 0,);
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_secure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'secure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_secure:
|
||||
|
||||
// nonsecure
|
||||
if ('/nonsecure' === $pathinfo) {
|
||||
$ret = array('_route' => 'nonsecure');
|
||||
$requiredSchemes = array ( 'http' => 0,);
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_nonsecure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_nonsecure:
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user