composer update
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
@@ -10,103 +9,27 @@ use Symfony\Component\Routing\RequestContext;
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
use PhpMatcherTrait;
|
||||
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = $allowSchemes = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$context = $this->context;
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
switch ($pathinfo) {
|
||||
case '/with-condition':
|
||||
// with-condition
|
||||
if (($context->getMethod() == "GET")) {
|
||||
return array('_route' => 'with-condition');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$routes = array(
|
||||
'/rootprefix/test' => array(array('_route' => 'static'), null, null, null),
|
||||
);
|
||||
|
||||
if (!isset($routes[$pathinfo])) {
|
||||
break;
|
||||
}
|
||||
list($ret, $requiredHost, $requiredMethods, $requiredSchemes) = $routes[$pathinfo];
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
$matchedPathinfo = $pathinfo;
|
||||
$regexList = array(
|
||||
$this->staticRoutes = array(
|
||||
'/rootprefix/test' => array(array(array('_route' => 'static'), null, null, null, false, null)),
|
||||
'/with-condition' => array(array(array('_route' => 'with-condition'), null, null, null, false, -1)),
|
||||
);
|
||||
$this->regexpList = array(
|
||||
0 => '{^(?'
|
||||
.'|/rootprefix/([^/]++)(*:27)'
|
||||
.')$}sD',
|
||||
.')(?:/?)$}sD',
|
||||
);
|
||||
|
||||
foreach ($regexList as $offset => $regex) {
|
||||
while (preg_match($regex, $matchedPathinfo, $matches)) {
|
||||
switch ($m = (int) $matches['MARK']) {
|
||||
default:
|
||||
$routes = array(
|
||||
27 => array(array('_route' => 'dynamic'), 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;
|
||||
}
|
||||
|
||||
if (27 === $m) {
|
||||
break;
|
||||
}
|
||||
$regex = substr_replace($regex, 'F', $m - $offset, 1 + strlen($m));
|
||||
$offset += strlen($m);
|
||||
$this->dynamicRoutes = array(
|
||||
27 => array(array(array('_route' => 'dynamic'), array('var'), null, null, false, null)),
|
||||
);
|
||||
$this->checkCondition = static function ($condition, $context, $request) {
|
||||
switch ($condition) {
|
||||
case -1: return ($context->getMethod() == "GET");
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw $allow ? new MethodNotAllowedException(array_keys($allow)) : new ResourceNotFoundException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user