update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
4
pfosten/vendor/symfony/routing/Matcher/Dumper/DumperCollection.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/routing/Matcher/Dumper/DumperCollection.php
vendored
Executable file → Normal file
|
|
@ -105,10 +105,8 @@ class DumperCollection implements \IteratorAggregate
|
|||
|
||||
/**
|
||||
* Sets the parent collection.
|
||||
*
|
||||
* @param DumperCollection $parent The parent collection
|
||||
*/
|
||||
protected function setParent(DumperCollection $parent)
|
||||
protected function setParent(self $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
|
|
|||
9
pfosten/vendor/symfony/routing/Matcher/Dumper/DumperRoute.php
vendored
Executable file → Normal file
9
pfosten/vendor/symfony/routing/Matcher/Dumper/DumperRoute.php
vendored
Executable file → Normal file
|
|
@ -22,19 +22,10 @@ use Symfony\Component\Routing\Route;
|
|||
*/
|
||||
class DumperRoute
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Route
|
||||
*/
|
||||
private $route;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The route name
|
||||
* @param Route $route The route
|
||||
*/
|
||||
|
|
|
|||
8
pfosten/vendor/symfony/routing/Matcher/Dumper/MatcherDumper.php
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/routing/Matcher/Dumper/MatcherDumper.php
vendored
Executable file → Normal file
|
|
@ -20,16 +20,8 @@ use Symfony\Component\Routing\RouteCollection;
|
|||
*/
|
||||
abstract class MatcherDumper implements MatcherDumperInterface
|
||||
{
|
||||
/**
|
||||
* @var RouteCollection
|
||||
*/
|
||||
private $routes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RouteCollection $routes The RouteCollection to dump
|
||||
*/
|
||||
public function __construct(RouteCollection $routes)
|
||||
{
|
||||
$this->routes = $routes;
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Matcher/Dumper/MatcherDumperInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Matcher/Dumper/MatcherDumperInterface.php
vendored
Executable file → Normal file
192
pfosten/vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php
vendored
Executable file → Normal file
192
pfosten/vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php
vendored
Executable file → Normal file
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Matcher\Dumper;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
/**
|
||||
* PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes.
|
||||
|
|
@ -63,16 +63,11 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* {$options['class']}.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class {$options['class']} extends {$options['base_class']}
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext \$context)
|
||||
{
|
||||
\$this->context = \$context;
|
||||
|
|
@ -101,21 +96,19 @@ EOF;
|
|||
$code = rtrim($this->compileRoutes($this->getRoutes(), $supportsRedirections), "\n");
|
||||
|
||||
return <<<EOF
|
||||
public function match(\$pathinfo)
|
||||
public function match(\$rawPathinfo)
|
||||
{
|
||||
\$allow = array();
|
||||
\$pathinfo = rawurldecode(\$pathinfo);
|
||||
\$pathinfo = rawurldecode(\$rawPathinfo);
|
||||
\$trimmedPathinfo = rtrim(\$pathinfo, '/');
|
||||
\$context = \$this->context;
|
||||
\$request = \$this->request;
|
||||
\$request = \$this->request ?: \$this->createRequest(\$pathinfo);
|
||||
\$requestMethod = \$canonicalMethod = \$context->getMethod();
|
||||
\$scheme = \$context->getScheme();
|
||||
|
||||
if ('HEAD' === \$requestMethod) {
|
||||
\$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
$code
|
||||
|
||||
throw 0 < count(\$allow) ? new MethodNotAllowedException(array_unique(\$allow)) : new ResourceNotFoundException();
|
||||
|
|
@ -160,6 +153,11 @@ EOF;
|
|||
}
|
||||
}
|
||||
|
||||
// used to display the Welcome Page in apps that don't define a homepage
|
||||
$code .= " if ('/' === \$pathinfo && !\$allow) {\n";
|
||||
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
|
||||
$code .= " }\n";
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +180,7 @@ EOF;
|
|||
*
|
||||
* @param StaticPrefixCollection $collection A StaticPrefixCollection instance
|
||||
* @param bool $supportsRedirections Whether redirections are supported by the base class
|
||||
* @param string $ifOrElseIf Either "if" or "elseif" to influence chaining.
|
||||
* @param string $ifOrElseIf either "if" or "elseif" to influence chaining
|
||||
*
|
||||
* @return string PHP code
|
||||
*/
|
||||
|
|
@ -238,11 +236,11 @@ EOF;
|
|||
$hostMatches = false;
|
||||
$methods = $route->getMethods();
|
||||
|
||||
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods) || in_array('GET', $methods));
|
||||
$supportsTrailingSlash = $supportsRedirections && (!$methods || \in_array('GET', $methods));
|
||||
$regex = $compiledRoute->getRegex();
|
||||
|
||||
if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#'.(substr($regex, -1) === 'u' ? 'u' : ''), $regex, $m)) {
|
||||
if ($supportsTrailingSlash && substr($m['url'], -1) === '/') {
|
||||
if (!\count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#'.('u' === substr($regex, -1) ? 'u' : ''), $regex, $m)) {
|
||||
if ($supportsTrailingSlash && '/' === substr($m['url'], -1)) {
|
||||
$conditions[] = sprintf('%s === $trimmedPathinfo', var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
|
||||
$hasTrailingSlash = true;
|
||||
} else {
|
||||
|
|
@ -280,83 +278,8 @@ EOF;
|
|||
|
||||
$gotoname = 'not_'.preg_replace('/[^A-Za-z0-9_]/', '', $name);
|
||||
|
||||
if ($methods) {
|
||||
if (1 === count($methods)) {
|
||||
if ($methods[0] === 'HEAD') {
|
||||
$code .= <<<EOF
|
||||
if ('HEAD' !== \$requestMethod) {
|
||||
\$allow[] = 'HEAD';
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
} else {
|
||||
$code .= <<<EOF
|
||||
if ('$methods[0]' !== \$canonicalMethod) {
|
||||
\$allow[] = '$methods[0]';
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
} else {
|
||||
$methodVariable = 'requestMethod';
|
||||
|
||||
if (in_array('GET', $methods)) {
|
||||
// Since we treat HEAD requests like GET requests we don't need to match it.
|
||||
$methodVariable = 'canonicalMethod';
|
||||
$methods = array_filter($methods, function ($method) { return 'HEAD' !== $method; });
|
||||
}
|
||||
|
||||
if (1 === count($methods)) {
|
||||
$code .= <<<EOF
|
||||
if ('$methods[0]' !== \$$methodVariable) {
|
||||
\$allow[] = '$methods[0]';
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
} else {
|
||||
$methods = implode("', '", $methods);
|
||||
$code .= <<<EOF
|
||||
if (!in_array(\$$methodVariable, array('$methods'))) {
|
||||
\$allow = array_merge(\$allow, array('$methods'));
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasTrailingSlash) {
|
||||
$code .= <<<EOF
|
||||
if (substr(\$pathinfo, -1) !== '/') {
|
||||
return \$this->redirect(\$pathinfo.'/', '$name');
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
if ($schemes = $route->getSchemes()) {
|
||||
if (!$supportsRedirections) {
|
||||
throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.');
|
||||
}
|
||||
$schemes = str_replace("\n", '', var_export(array_flip($schemes), true));
|
||||
$code .= <<<EOF
|
||||
\$requiredSchemes = $schemes;
|
||||
if (!isset(\$requiredSchemes[\$scheme])) {
|
||||
return \$this->redirect(\$pathinfo, '$name', key(\$requiredSchemes));
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
// the offset where the return value is appended below, with indendation
|
||||
$retOffset = 12 + \strlen($code);
|
||||
|
||||
// optimize parameters array
|
||||
if ($matches || $hostMatches) {
|
||||
|
|
@ -370,18 +293,93 @@ EOF;
|
|||
$vars[] = "array('_route' => '$name')";
|
||||
|
||||
$code .= sprintf(
|
||||
" return \$this->mergeDefaults(array_replace(%s), %s);\n",
|
||||
" \$ret = \$this->mergeDefaults(array_replace(%s), %s);\n",
|
||||
implode(', ', $vars),
|
||||
str_replace("\n", '', var_export($route->getDefaults(), true))
|
||||
);
|
||||
} elseif ($route->getDefaults()) {
|
||||
$code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true)));
|
||||
$code .= sprintf(" \$ret = %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true)));
|
||||
} else {
|
||||
$code .= sprintf(" return array('_route' => '%s');\n", $name);
|
||||
$code .= sprintf(" \$ret = array('_route' => '%s');\n", $name);
|
||||
}
|
||||
|
||||
if ($hasTrailingSlash) {
|
||||
$code .= <<<EOF
|
||||
if ('/' === substr(\$pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== \$canonicalMethod) {
|
||||
goto $gotoname;
|
||||
} else {
|
||||
return array_replace(\$ret, \$this->redirect(\$rawPathinfo.'/', '$name'));
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
if ($methods) {
|
||||
$methodVariable = \in_array('GET', $methods) ? '$canonicalMethod' : '$requestMethod';
|
||||
$methods = implode("', '", $methods);
|
||||
}
|
||||
|
||||
if ($schemes = $route->getSchemes()) {
|
||||
if (!$supportsRedirections) {
|
||||
throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.');
|
||||
}
|
||||
$schemes = str_replace("\n", '', var_export(array_flip($schemes), true));
|
||||
if ($methods) {
|
||||
$code .= <<<EOF
|
||||
\$requiredSchemes = $schemes;
|
||||
\$hasRequiredScheme = isset(\$requiredSchemes[\$context->getScheme()]);
|
||||
if (!in_array($methodVariable, array('$methods'))) {
|
||||
if (\$hasRequiredScheme) {
|
||||
\$allow = array_merge(\$allow, array('$methods'));
|
||||
}
|
||||
goto $gotoname;
|
||||
}
|
||||
if (!\$hasRequiredScheme) {
|
||||
if ('GET' !== \$canonicalMethod) {
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
return array_replace(\$ret, \$this->redirect(\$rawPathinfo, '$name', key(\$requiredSchemes)));
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
} else {
|
||||
$code .= <<<EOF
|
||||
\$requiredSchemes = $schemes;
|
||||
if (!isset(\$requiredSchemes[\$context->getScheme()])) {
|
||||
if ('GET' !== \$canonicalMethod) {
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
return array_replace(\$ret, \$this->redirect(\$rawPathinfo, '$name', key(\$requiredSchemes)));
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
} elseif ($methods) {
|
||||
$code .= <<<EOF
|
||||
if (!in_array($methodVariable, array('$methods'))) {
|
||||
\$allow = array_merge(\$allow, array('$methods'));
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
if ($hasTrailingSlash || $schemes || $methods) {
|
||||
$code .= " return \$ret;\n";
|
||||
} else {
|
||||
$code = substr_replace($code, 'return', $retOffset, 6);
|
||||
}
|
||||
$code .= " }\n";
|
||||
|
||||
if ($methods) {
|
||||
if ($hasTrailingSlash || $schemes || $methods) {
|
||||
$code .= " $gotoname:\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
16
pfosten/vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php
vendored
Executable file → Normal file
16
pfosten/vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php
vendored
Executable file → Normal file
|
|
@ -69,7 +69,7 @@ class StaticPrefixCollection
|
|||
// This is needed because otherwise routes that come afterwards have higher precedence
|
||||
// than a possible regular expression, which goes against the input order sorting.
|
||||
$this->items[] = array($prefix, $route);
|
||||
$this->matchStart = count($this->items);
|
||||
$this->matchStart = \count($this->items);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ class StaticPrefixCollection
|
|||
*/
|
||||
private function accepts($prefix)
|
||||
{
|
||||
return '' === $this->prefix || strpos($prefix, $this->prefix) === 0;
|
||||
return '' === $this->prefix || 0 === strpos($prefix, $this->prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,9 +152,9 @@ class StaticPrefixCollection
|
|||
*/
|
||||
private function detectCommonPrefix($prefix, $anotherPrefix)
|
||||
{
|
||||
$baseLength = strlen($this->prefix);
|
||||
$baseLength = \strlen($this->prefix);
|
||||
$commonLength = $baseLength;
|
||||
$end = min(strlen($prefix), strlen($anotherPrefix));
|
||||
$end = min(\strlen($prefix), \strlen($anotherPrefix));
|
||||
|
||||
for ($i = $baseLength; $i <= $end; ++$i) {
|
||||
if (substr($prefix, 0, $i) !== substr($anotherPrefix, 0, $i)) {
|
||||
|
|
@ -166,7 +166,7 @@ class StaticPrefixCollection
|
|||
|
||||
$commonPrefix = rtrim(substr($prefix, 0, $commonLength), '/');
|
||||
|
||||
if (strlen($commonPrefix) > $baseLength) {
|
||||
if (\strlen($commonPrefix) > $baseLength) {
|
||||
return $commonPrefix;
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ class StaticPrefixCollection
|
|||
|
||||
private function shouldBeInlined()
|
||||
{
|
||||
if (count($this->items) >= 3) {
|
||||
if (\count($this->items) >= 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ class StaticPrefixCollection
|
|||
}
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
if (is_array($item) && $item[0] === $this->prefix) {
|
||||
if (\is_array($item) && $item[0] === $this->prefix) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ class StaticPrefixCollection
|
|||
*
|
||||
* @param string $prefix
|
||||
*
|
||||
* @throws \LogicException When a prefix does not belong in a group.
|
||||
* @throws \LogicException when a prefix does not belong in a group
|
||||
*/
|
||||
private function guardAgainstAddingNotAcceptedRoutes($prefix)
|
||||
{
|
||||
|
|
|
|||
8
pfosten/vendor/symfony/routing/Matcher/RedirectableUrlMatcher.php
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/routing/Matcher/RedirectableUrlMatcher.php
vendored
Executable file → Normal file
|
|
@ -27,14 +27,14 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable
|
|||
try {
|
||||
$parameters = parent::match($pathinfo);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
if ('/' === substr($pathinfo, -1) || !in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
|
||||
if ('/' === substr($pathinfo, -1) || !\in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try {
|
||||
parent::match($pathinfo.'/');
|
||||
$parameters = parent::match($pathinfo.'/');
|
||||
|
||||
return $this->redirect($pathinfo.'/', null);
|
||||
return array_replace($parameters, $this->redirect($pathinfo.'/', isset($parameters['_route']) ? $parameters['_route'] : null));
|
||||
} catch (ResourceNotFoundException $e2) {
|
||||
throw $e;
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable
|
|||
protected function handleRouteRequirements($pathinfo, $name, Route $route)
|
||||
{
|
||||
// expression condition
|
||||
if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) {
|
||||
if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)))) {
|
||||
return array(self::REQUIREMENT_MISMATCH, null);
|
||||
}
|
||||
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Matcher/RedirectableUrlMatcherInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Matcher/RedirectableUrlMatcherInterface.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/routing/Matcher/RequestMatcherInterface.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/routing/Matcher/RequestMatcherInterface.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,9 @@
|
|||
namespace Symfony\Component\Routing\Matcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\NoConfigurationException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* RequestMatcherInterface is the interface that all request matcher classes must implement.
|
||||
|
|
@ -28,10 +29,9 @@ interface RequestMatcherInterface
|
|||
* If the matcher can not find information, it must throw one of the exceptions documented
|
||||
* below.
|
||||
*
|
||||
* @param Request $request The request to match
|
||||
*
|
||||
* @return array An array of parameters
|
||||
*
|
||||
* @throws NoConfigurationException If no routing configuration could be found
|
||||
* @throws ResourceNotFoundException If no matching resource could be found
|
||||
* @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed
|
||||
*/
|
||||
|
|
|
|||
6
pfosten/vendor/symfony/routing/Matcher/TraceableUrlMatcher.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/routing/Matcher/TraceableUrlMatcher.php
vendored
Executable file → Normal file
|
|
@ -69,7 +69,7 @@ class TraceableUrlMatcher extends UrlMatcher
|
|||
$r = new Route($route->getPath(), $route->getDefaults(), array($n => $regex), $route->getOptions());
|
||||
$cr = $r->compile();
|
||||
|
||||
if (in_array($n, $cr->getVariables()) && !preg_match($cr->getRegex(), $pathinfo)) {
|
||||
if (\in_array($n, $cr->getVariables()) && !preg_match($cr->getRegex(), $pathinfo)) {
|
||||
$this->addTrace(sprintf('Requirement for "%s" does not match (%s)', $n, $regex), self::ROUTE_ALMOST_MATCHES, $name, $route);
|
||||
|
||||
continue 2;
|
||||
|
|
@ -94,7 +94,7 @@ class TraceableUrlMatcher extends UrlMatcher
|
|||
$method = 'GET';
|
||||
}
|
||||
|
||||
if (!in_array($method, $requiredMethods)) {
|
||||
if (!\in_array($method, $requiredMethods)) {
|
||||
$this->allow = array_merge($this->allow, $requiredMethods);
|
||||
|
||||
$this->addTrace(sprintf('Method "%s" does not match any of the required methods (%s)', $this->context->getMethod(), implode(', ', $requiredMethods)), self::ROUTE_ALMOST_MATCHES, $name, $route);
|
||||
|
|
@ -105,7 +105,7 @@ class TraceableUrlMatcher extends UrlMatcher
|
|||
|
||||
// check condition
|
||||
if ($condition = $route->getCondition()) {
|
||||
if (!$this->getExpressionLanguage()->evaluate($condition, array('context' => $this->context, 'request' => $this->request))) {
|
||||
if (!$this->getExpressionLanguage()->evaluate($condition, array('context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)))) {
|
||||
$this->addTrace(sprintf('Condition "%s" does not evaluate to "true"', $condition), self::ROUTE_ALMOST_MATCHES, $name, $route);
|
||||
|
||||
continue;
|
||||
|
|
|
|||
77
pfosten/vendor/symfony/routing/Matcher/UrlMatcher.php
vendored
Executable file → Normal file
77
pfosten/vendor/symfony/routing/Matcher/UrlMatcher.php
vendored
Executable file → Normal file
|
|
@ -11,14 +11,15 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Matcher;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\NoConfigurationException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* UrlMatcher matches URL based on a set of routes.
|
||||
|
|
@ -31,21 +32,9 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
const REQUIREMENT_MISMATCH = 1;
|
||||
const ROUTE_MATCH = 2;
|
||||
|
||||
/**
|
||||
* @var RequestContext
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $allow = array();
|
||||
|
||||
/**
|
||||
* @var RouteCollection
|
||||
*/
|
||||
protected $routes;
|
||||
|
||||
protected $request;
|
||||
protected $expressionLanguage;
|
||||
|
||||
|
|
@ -54,12 +43,6 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
*/
|
||||
protected $expressionLanguageProviders = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RouteCollection $routes A RouteCollection instance
|
||||
* @param RequestContext $context The context
|
||||
*/
|
||||
public function __construct(RouteCollection $routes, RequestContext $context)
|
||||
{
|
||||
$this->routes = $routes;
|
||||
|
|
@ -93,7 +76,11 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
return $ret;
|
||||
}
|
||||
|
||||
throw 0 < count($this->allow)
|
||||
if ('/' === $pathinfo && !$this->allow) {
|
||||
throw new NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < \count($this->allow)
|
||||
? new MethodNotAllowedException(array_unique($this->allow))
|
||||
: new ResourceNotFoundException(sprintf('No routes found for "%s".', $pathinfo));
|
||||
}
|
||||
|
|
@ -125,6 +112,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
*
|
||||
* @return array An array of parameters
|
||||
*
|
||||
* @throws NoConfigurationException If no routing configuration could be found
|
||||
* @throws ResourceNotFoundException If the resource could not be found
|
||||
* @throws MethodNotAllowedException If the resource was found but the request method is not allowed
|
||||
*/
|
||||
|
|
@ -147,6 +135,12 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
$status = $this->handleRouteRequirements($pathinfo, $name, $route);
|
||||
|
||||
if (self::REQUIREMENT_MISMATCH === $status[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check HTTP method requirement
|
||||
if ($requiredMethods = $route->getMethods()) {
|
||||
// HEAD and GET are equivalent as per RFC
|
||||
|
|
@ -154,24 +148,16 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
$method = 'GET';
|
||||
}
|
||||
|
||||
if (!in_array($method, $requiredMethods)) {
|
||||
$this->allow = array_merge($this->allow, $requiredMethods);
|
||||
if (!\in_array($method, $requiredMethods)) {
|
||||
if (self::REQUIREMENT_MATCH === $status[0]) {
|
||||
$this->allow = array_merge($this->allow, $requiredMethods);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$status = $this->handleRouteRequirements($pathinfo, $name, $route);
|
||||
|
||||
if (self::ROUTE_MATCH === $status[0]) {
|
||||
return $status[1];
|
||||
}
|
||||
|
||||
if (self::REQUIREMENT_MISMATCH === $status[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches));
|
||||
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, isset($status[1]) ? $status[1] : array()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +193,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
protected function handleRouteRequirements($pathinfo, $name, Route $route)
|
||||
{
|
||||
// expression condition
|
||||
if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) {
|
||||
if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)))) {
|
||||
return array(self::REQUIREMENT_MISMATCH, null);
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +215,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
protected function mergeDefaults($params, $defaults)
|
||||
{
|
||||
foreach ($params as $key => $value) {
|
||||
if (!is_int($key)) {
|
||||
if (!\is_int($key)) {
|
||||
$defaults[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
|
@ -248,4 +234,19 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
|||
|
||||
return $this->expressionLanguage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected function createRequest($pathinfo)
|
||||
{
|
||||
if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Request::create($this->context->getScheme().'://'.$this->context->getHost().$this->context->getBaseUrl().$pathinfo, $this->context->getMethod(), $this->context->getParameters(), array(), array(), array(
|
||||
'SCRIPT_FILENAME' => $this->context->getBaseUrl(),
|
||||
'SCRIPT_NAME' => $this->context->getBaseUrl(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
6
pfosten/vendor/symfony/routing/Matcher/UrlMatcherInterface.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/routing/Matcher/UrlMatcherInterface.php
vendored
Executable file → Normal file
|
|
@ -11,9 +11,10 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Matcher;
|
||||
|
||||
use Symfony\Component\Routing\RequestContextAwareInterface;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\NoConfigurationException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContextAwareInterface;
|
||||
|
||||
/**
|
||||
* UrlMatcherInterface is the interface that all URL matcher classes must implement.
|
||||
|
|
@ -32,6 +33,7 @@ interface UrlMatcherInterface extends RequestContextAwareInterface
|
|||
*
|
||||
* @return array An array of parameters
|
||||
*
|
||||
* @throws NoConfigurationException If no routing configuration could be found
|
||||
* @throws ResourceNotFoundException If the resource could not be found
|
||||
* @throws MethodNotAllowedException If the resource was found but the request method is not allowed
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue