Laravel version update
Laravel version update
This commit is contained in:
8
vendor/symfony/routing/Annotation/Route.php
vendored
8
vendor/symfony/routing/Annotation/Route.php
vendored
@@ -32,8 +32,6 @@ class Route
|
||||
private $condition;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data An array of key/value parameters
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
@@ -48,7 +46,7 @@ class Route
|
||||
foreach ($data as $key => $value) {
|
||||
$method = 'set'.str_replace('_', '', $key);
|
||||
if (!method_exists($this, $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, get_class($this)));
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, \get_class($this)));
|
||||
}
|
||||
$this->$method($value);
|
||||
}
|
||||
@@ -116,7 +114,7 @@ class Route
|
||||
|
||||
public function setSchemes($schemes)
|
||||
{
|
||||
$this->schemes = is_array($schemes) ? $schemes : array($schemes);
|
||||
$this->schemes = \is_array($schemes) ? $schemes : array($schemes);
|
||||
}
|
||||
|
||||
public function getSchemes()
|
||||
@@ -126,7 +124,7 @@ class Route
|
||||
|
||||
public function setMethods($methods)
|
||||
{
|
||||
$this->methods = is_array($methods) ? $methods : array($methods);
|
||||
$this->methods = \is_array($methods) ? $methods : array($methods);
|
||||
}
|
||||
|
||||
public function getMethods()
|
||||
|
28
vendor/symfony/routing/CHANGELOG.md
vendored
28
vendor/symfony/routing/CHANGELOG.md
vendored
@@ -1,6 +1,34 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* Added `NoConfigurationException`.
|
||||
* Added the possibility to define a prefix for all routes of a controller via @Route(name="prefix_")
|
||||
* Added support for prioritized routing loaders.
|
||||
* Add matched and default parameters to redirect responses
|
||||
* Added support for a `controller` keyword for configuring route controllers in YAML and XML configurations.
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* [DEPRECATION] Class parameters have been deprecated and will be removed in 4.0.
|
||||
* router.options.generator_class
|
||||
* router.options.generator_base_class
|
||||
* router.options.generator_dumper_class
|
||||
* router.options.matcher_class
|
||||
* router.options.matcher_base_class
|
||||
* router.options.matcher_dumper_class
|
||||
* router.options.matcher.cache_class
|
||||
* router.options.generator.cache_class
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
* Added support for `bool`, `int`, `float`, `string`, `list` and `map` defaults in XML configurations.
|
||||
* Added support for UTF-8 requirements
|
||||
|
||||
2.8.0
|
||||
-----
|
||||
|
||||
|
9
vendor/symfony/routing/CompiledRoute.php
vendored
9
vendor/symfony/routing/CompiledRoute.php
vendored
@@ -28,8 +28,6 @@ class CompiledRoute implements \Serializable
|
||||
private $hostTokens;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $staticPrefix The static prefix of the compiled route
|
||||
* @param string $regex The regular expression to use to match this route
|
||||
* @param array $tokens An array of tokens to use to generate URL for this route
|
||||
@@ -73,7 +71,12 @@ class CompiledRoute implements \Serializable
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$data = unserialize($serialized);
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
$data = unserialize($serialized, array('allowed_classes' => false));
|
||||
} else {
|
||||
$data = unserialize($serialized);
|
||||
}
|
||||
|
||||
$this->variables = $data['vars'];
|
||||
$this->staticPrefix = $data['path_prefix'];
|
||||
$this->regex = $data['path_regex'];
|
||||
|
49
vendor/symfony/routing/DependencyInjection/RoutingResolverPass.php
vendored
Normal file
49
vendor/symfony/routing/DependencyInjection/RoutingResolverPass.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Adds tagged routing.loader services to routing.resolver service.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class RoutingResolverPass implements CompilerPassInterface
|
||||
{
|
||||
use PriorityTaggedServiceTrait;
|
||||
|
||||
private $resolverServiceId;
|
||||
private $loaderTag;
|
||||
|
||||
public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader')
|
||||
{
|
||||
$this->resolverServiceId = $resolverServiceId;
|
||||
$this->loaderTag = $loaderTag;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (false === $container->hasDefinition($this->resolverServiceId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->getDefinition($this->resolverServiceId);
|
||||
|
||||
foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) {
|
||||
$definition->addMethodCall('addLoader', array(new Reference($id)));
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,9 +20,6 @@ namespace Symfony\Component\Routing\Exception;
|
||||
*/
|
||||
class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $allowedMethods = array();
|
||||
|
||||
public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null)
|
||||
|
21
vendor/symfony/routing/Exception/NoConfigurationException.php
vendored
Normal file
21
vendor/symfony/routing/Exception/NoConfigurationException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown when no routes are configured.
|
||||
*
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*/
|
||||
class NoConfigurationException extends ResourceNotFoundException
|
||||
{
|
||||
}
|
@@ -20,16 +20,8 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
*/
|
||||
abstract class GeneratorDumper implements GeneratorDumperInterface
|
||||
{
|
||||
/**
|
||||
* @var RouteCollection
|
||||
*/
|
||||
private $routes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RouteCollection $routes The RouteCollection to dump
|
||||
*/
|
||||
public function __construct(RouteCollection $routes)
|
||||
{
|
||||
$this->routes = $routes;
|
||||
|
@@ -46,8 +46,6 @@ use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* {$options['class']}
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
@@ -55,9 +53,6 @@ class {$options['class']} extends {$options['base_class']}
|
||||
{
|
||||
private static \$declaredRoutes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext \$context, LoggerInterface \$logger = null)
|
||||
{
|
||||
\$this->context = \$context;
|
||||
|
133
vendor/symfony/routing/Generator/UrlGenerator.php
vendored
133
vendor/symfony/routing/Generator/UrlGenerator.php
vendored
@@ -11,12 +11,12 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Generator;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Exception\InvalidParameterException;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Routing\Exception\InvalidParameterException;
|
||||
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* UrlGenerator can generate a URL or a path for any route in the RouteCollection
|
||||
@@ -27,14 +27,7 @@ use Psr\Log\LoggerInterface;
|
||||
*/
|
||||
class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface
|
||||
{
|
||||
/**
|
||||
* @var RouteCollection
|
||||
*/
|
||||
protected $routes;
|
||||
|
||||
/**
|
||||
* @var RequestContext
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
@@ -42,9 +35,6 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
*/
|
||||
protected $strictRequirements = true;
|
||||
|
||||
/**
|
||||
* @var LoggerInterface|null
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
@@ -75,13 +65,6 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
'%7C' => '|',
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RouteCollection $routes A RouteCollection instance
|
||||
* @param RequestContext $context The context
|
||||
* @param LoggerInterface|null $logger A logger instance
|
||||
*/
|
||||
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->routes = $routes;
|
||||
@@ -153,18 +136,18 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
|
||||
$url = '';
|
||||
$optional = true;
|
||||
$message = 'Parameter "{parameter}" for route "{route}" must match "{expected}" ("{given}" given) to generate a corresponding URL.';
|
||||
foreach ($tokens as $token) {
|
||||
if ('variable' === $token[0]) {
|
||||
if (!$optional || !array_key_exists($token[3], $defaults) || null !== $mergedParams[$token[3]] && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) {
|
||||
// check requirement
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#', $mergedParams[$token[3]])) {
|
||||
$message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]);
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
|
||||
if ($this->strictRequirements) {
|
||||
throw new InvalidParameterException($message);
|
||||
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
|
||||
}
|
||||
|
||||
if ($this->logger) {
|
||||
$this->logger->error($message);
|
||||
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -198,61 +181,58 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
}
|
||||
|
||||
$schemeAuthority = '';
|
||||
if ($host = $this->context->getHost()) {
|
||||
$scheme = $this->context->getScheme();
|
||||
$host = $this->context->getHost();
|
||||
$scheme = $this->context->getScheme();
|
||||
|
||||
if ($requiredSchemes) {
|
||||
if (!in_array($scheme, $requiredSchemes, true)) {
|
||||
$referenceType = self::ABSOLUTE_URL;
|
||||
$scheme = current($requiredSchemes);
|
||||
}
|
||||
if ($requiredSchemes) {
|
||||
if (!\in_array($scheme, $requiredSchemes, true)) {
|
||||
$referenceType = self::ABSOLUTE_URL;
|
||||
$scheme = current($requiredSchemes);
|
||||
}
|
||||
}
|
||||
|
||||
if ($hostTokens) {
|
||||
$routeHost = '';
|
||||
foreach ($hostTokens as $token) {
|
||||
if ('variable' === $token[0]) {
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i', $mergedParams[$token[3]])) {
|
||||
$message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]);
|
||||
|
||||
if ($this->strictRequirements) {
|
||||
throw new InvalidParameterException($message);
|
||||
}
|
||||
|
||||
if ($this->logger) {
|
||||
$this->logger->error($message);
|
||||
}
|
||||
|
||||
return;
|
||||
if ($hostTokens) {
|
||||
$routeHost = '';
|
||||
foreach ($hostTokens as $token) {
|
||||
if ('variable' === $token[0]) {
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
|
||||
if ($this->strictRequirements) {
|
||||
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
|
||||
}
|
||||
|
||||
$routeHost = $token[1].$mergedParams[$token[3]].$routeHost;
|
||||
} else {
|
||||
$routeHost = $token[1].$routeHost;
|
||||
}
|
||||
}
|
||||
if ($this->logger) {
|
||||
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
|
||||
}
|
||||
|
||||
if ($routeHost !== $host) {
|
||||
$host = $routeHost;
|
||||
if (self::ABSOLUTE_URL !== $referenceType) {
|
||||
$referenceType = self::NETWORK_PATH;
|
||||
return;
|
||||
}
|
||||
|
||||
$routeHost = $token[1].$mergedParams[$token[3]].$routeHost;
|
||||
} else {
|
||||
$routeHost = $token[1].$routeHost;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) {
|
||||
$port = '';
|
||||
if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
|
||||
$port = ':'.$this->context->getHttpPort();
|
||||
} elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
|
||||
$port = ':'.$this->context->getHttpsPort();
|
||||
if ($routeHost !== $host) {
|
||||
$host = $routeHost;
|
||||
if (self::ABSOLUTE_URL !== $referenceType) {
|
||||
$referenceType = self::NETWORK_PATH;
|
||||
}
|
||||
|
||||
$schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://";
|
||||
$schemeAuthority .= $host.$port;
|
||||
}
|
||||
}
|
||||
|
||||
if ((self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) && !empty($host)) {
|
||||
$port = '';
|
||||
if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
|
||||
$port = ':'.$this->context->getHttpPort();
|
||||
} elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
|
||||
$port = ':'.$this->context->getHttpsPort();
|
||||
}
|
||||
|
||||
$schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://";
|
||||
$schemeAuthority .= $host.$port;
|
||||
}
|
||||
|
||||
if (self::RELATIVE_PATH === $referenceType) {
|
||||
$url = self::getRelativePath($this->context->getPathInfo(), $url);
|
||||
} else {
|
||||
@@ -264,12 +244,27 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
return $a == $b ? 0 : 1;
|
||||
});
|
||||
|
||||
if ($extra && $query = http_build_query($extra, '', '&')) {
|
||||
// extract fragment
|
||||
$fragment = '';
|
||||
if (isset($defaults['_fragment'])) {
|
||||
$fragment = $defaults['_fragment'];
|
||||
}
|
||||
|
||||
if (isset($extra['_fragment'])) {
|
||||
$fragment = $extra['_fragment'];
|
||||
unset($extra['_fragment']);
|
||||
}
|
||||
|
||||
if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) {
|
||||
// "/" and "?" can be left decoded for better user experience, see
|
||||
// http://tools.ietf.org/html/rfc3986#section-3.4
|
||||
$url .= '?'.strtr($query, array('%2F' => '/'));
|
||||
}
|
||||
|
||||
if ('' !== $fragment) {
|
||||
$url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?'));
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@@ -313,7 +308,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
}
|
||||
|
||||
$targetDirs[] = $targetFile;
|
||||
$path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs);
|
||||
$path = str_repeat('../', \count($sourceDirs)).implode('/', $targetDirs);
|
||||
|
||||
// A reference to the same base directory or an empty subdirectory must be prefixed with "./".
|
||||
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
|
||||
|
@@ -69,6 +69,8 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
*
|
||||
* If there is no route with the given name, the generator must throw the RouteNotFoundException.
|
||||
*
|
||||
* The special parameter _fragment will be used as the document fragment suffixed to the final URL.
|
||||
*
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param int $referenceType The type of reference to be generated (one of the constants)
|
||||
|
2
vendor/symfony/routing/LICENSE
vendored
2
vendor/symfony/routing/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2016 Fabien Potencier
|
||||
Copyright (c) 2004-2018 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -12,11 +12,11 @@
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
||||
|
||||
/**
|
||||
* AnnotationClassLoader loads routing information from a PHP class and its methods.
|
||||
@@ -57,9 +57,6 @@ use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
||||
*/
|
||||
abstract class AnnotationClassLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var Reader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
@@ -72,11 +69,6 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
*/
|
||||
protected $defaultRouteIndex = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Reader $reader
|
||||
*/
|
||||
public function __construct(Reader $reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
@@ -127,6 +119,17 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (0 === $collection->count() && $class->hasMethod('__invoke')) {
|
||||
foreach ($this->reader->getClassAnnotations($class) as $annot) {
|
||||
if ($annot instanceof $this->routeAnnotationClass) {
|
||||
$globals['path'] = '';
|
||||
$globals['name'] = '';
|
||||
|
||||
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
@@ -136,10 +139,11 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
if (null === $name) {
|
||||
$name = $this->getDefaultRouteName($class, $method);
|
||||
}
|
||||
$name = $globals['name'].$name;
|
||||
|
||||
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
|
||||
foreach ($method->getParameters() as $param) {
|
||||
if (!isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
|
||||
if (false !== strpos($globals['path'].$annot->getPath(), sprintf('{%s}', $param->getName())) && !isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
|
||||
$defaults[$param->getName()] = $param->getDefaultValue();
|
||||
}
|
||||
}
|
||||
@@ -170,7 +174,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type);
|
||||
return \is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,9 +221,14 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
'methods' => array(),
|
||||
'host' => '',
|
||||
'condition' => '',
|
||||
'name' => '',
|
||||
);
|
||||
|
||||
if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) {
|
||||
if (null !== $annot->getName()) {
|
||||
$globals['name'] = $annot->getName();
|
||||
}
|
||||
|
||||
if (null !== $annot->getPath()) {
|
||||
$globals['path'] = $annot->getPath();
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* AnnotationDirectoryLoader loads routing information from annotations set
|
||||
@@ -34,11 +34,21 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
|
||||
*/
|
||||
public function load($path, $type = null)
|
||||
{
|
||||
$dir = $this->locator->locate($path);
|
||||
if (!is_dir($dir = $this->locator->locate($path))) {
|
||||
return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();
|
||||
}
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->addResource(new DirectoryResource($dir, '/\.php$/'));
|
||||
$files = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY));
|
||||
$files = iterator_to_array(new \RecursiveIteratorIterator(
|
||||
new \RecursiveCallbackFilterIterator(
|
||||
new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
|
||||
function (\SplFileInfo $current) {
|
||||
return '.' !== substr($current->getBasename(), 0, 1);
|
||||
}
|
||||
),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||
));
|
||||
usort($files, function (\SplFileInfo $a, \SplFileInfo $b) {
|
||||
return (string) $a > (string) $b ? 1 : -1;
|
||||
});
|
||||
@@ -66,16 +76,18 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
if (!is_string($resource)) {
|
||||
if ('annotation' === $type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($type || !\is_string($resource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$path = $this->locator->locate($resource);
|
||||
return is_dir($this->locator->locate($resource));
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_dir($path) && (!$type || 'annotation' === $type);
|
||||
}
|
||||
}
|
||||
|
@@ -11,10 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Config\FileLocatorInterface;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* AnnotationFileLoader loads routing information from annotations set
|
||||
@@ -27,16 +27,11 @@ class AnnotationFileLoader extends FileLoader
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param FileLocatorInterface $locator A FileLocator instance
|
||||
* @param AnnotationClassLoader $loader An AnnotationClassLoader instance
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader)
|
||||
{
|
||||
if (!function_exists('token_get_all')) {
|
||||
if (!\function_exists('token_get_all')) {
|
||||
throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.');
|
||||
}
|
||||
|
||||
@@ -64,7 +59,7 @@ class AnnotationFileLoader extends FileLoader
|
||||
$collection->addResource(new FileResource($path));
|
||||
$collection->addCollection($this->loader->load($class, $type));
|
||||
}
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
|
||||
gc_mem_caches();
|
||||
}
|
||||
@@ -77,7 +72,7 @@ class AnnotationFileLoader extends FileLoader
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type);
|
||||
return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,6 +87,11 @@ class AnnotationFileLoader extends FileLoader
|
||||
$class = false;
|
||||
$namespace = false;
|
||||
$tokens = token_get_all(file_get_contents($file));
|
||||
|
||||
if (1 === \count($tokens) && T_INLINE_HTML === $tokens[0][0]) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain PHP code. Did you forgot to add the "<?php" start tag at the beginning of the file?', $file));
|
||||
}
|
||||
|
||||
for ($i = 0; isset($tokens[$i]); ++$i) {
|
||||
$token = $tokens[$i];
|
||||
|
||||
@@ -105,29 +105,29 @@ class AnnotationFileLoader extends FileLoader
|
||||
|
||||
if (true === $namespace && T_STRING === $token[0]) {
|
||||
$namespace = $token[1];
|
||||
while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_NS_SEPARATOR, T_STRING))) {
|
||||
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], array(T_NS_SEPARATOR, T_STRING))) {
|
||||
$namespace .= $tokens[$i][1];
|
||||
}
|
||||
$token = $tokens[$i];
|
||||
}
|
||||
|
||||
if (T_CLASS === $token[0]) {
|
||||
// Skip usage of ::class constant
|
||||
$isClassConstant = false;
|
||||
// Skip usage of ::class constant and anonymous classes
|
||||
$skipClassToken = false;
|
||||
for ($j = $i - 1; $j > 0; --$j) {
|
||||
if (!isset($tokens[$j][1])) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||
$isClassConstant = true;
|
||||
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
|
||||
$skipClassToken = true;
|
||||
break;
|
||||
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
|
||||
} elseif (!\in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isClassConstant) {
|
||||
if (!$skipClassToken) {
|
||||
$class = true;
|
||||
}
|
||||
}
|
||||
|
81
vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php
vendored
Normal file
81
vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CollectionConfigurator
|
||||
{
|
||||
use Traits\AddTrait;
|
||||
use Traits\RouteTrait;
|
||||
|
||||
private $parent;
|
||||
private $parentConfigurator;
|
||||
|
||||
public function __construct(RouteCollection $parent, $name, self $parentConfigurator = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->name = $name;
|
||||
$this->collection = new RouteCollection();
|
||||
$this->route = new Route('');
|
||||
$this->parentConfigurator = $parentConfigurator; // for GC control
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->collection->addPrefix(rtrim($this->route->getPath(), '/'));
|
||||
$this->parent->addCollection($this->collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
*
|
||||
* @return RouteConfigurator
|
||||
*/
|
||||
final public function add($name, $path)
|
||||
{
|
||||
$this->collection->add($this->name.$name, $route = clone $this->route);
|
||||
|
||||
return new RouteConfigurator($this->collection, $route->setPath($path), $this->name, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sub-collection.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
final public function collection($name = '')
|
||||
{
|
||||
return new self($this->collection, $this->name.$name, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the prefix to add to the path of all child routes.
|
||||
*
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function prefix($prefix)
|
||||
{
|
||||
$this->route->setPath($prefix);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
49
vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php
vendored
Normal file
49
vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ImportConfigurator
|
||||
{
|
||||
use Traits\RouteTrait;
|
||||
|
||||
private $parent;
|
||||
|
||||
public function __construct(RouteCollection $parent, RouteCollection $route)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->route = $route;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->parent->addCollection($this->route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the prefix to add to the path of all child routes.
|
||||
*
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function prefix($prefix)
|
||||
{
|
||||
$this->route->addPrefix($prefix);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
34
vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php
vendored
Normal file
34
vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class RouteConfigurator
|
||||
{
|
||||
use Traits\AddTrait;
|
||||
use Traits\RouteTrait;
|
||||
|
||||
private $parentConfigurator;
|
||||
|
||||
public function __construct(RouteCollection $collection, Route $route, $name = '', CollectionConfigurator $parentConfigurator = null)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
$this->route = $route;
|
||||
$this->name = $name;
|
||||
$this->parentConfigurator = $parentConfigurator; // for GC control
|
||||
}
|
||||
}
|
62
vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php
vendored
Normal file
62
vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Routing\Loader\PhpFileLoader;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class RoutingConfigurator
|
||||
{
|
||||
use Traits\AddTrait;
|
||||
|
||||
private $loader;
|
||||
private $path;
|
||||
private $file;
|
||||
|
||||
public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
$this->loader = $loader;
|
||||
$this->path = $path;
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImportConfigurator
|
||||
*/
|
||||
final public function import($resource, $type = null, $ignoreErrors = false)
|
||||
{
|
||||
$this->loader->setCurrentDir(\dirname($this->path));
|
||||
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
|
||||
if (!\is_array($imported)) {
|
||||
return new ImportConfigurator($this->collection, $imported);
|
||||
}
|
||||
|
||||
$mergedCollection = new RouteCollection();
|
||||
foreach ($imported as $subCollection) {
|
||||
$mergedCollection->addCollection($subCollection);
|
||||
}
|
||||
|
||||
return new ImportConfigurator($this->collection, $mergedCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CollectionConfigurator
|
||||
*/
|
||||
final public function collection($name = '')
|
||||
{
|
||||
return new CollectionConfigurator($this->collection, $name);
|
||||
}
|
||||
}
|
55
vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php
vendored
Normal file
55
vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator\Traits;
|
||||
|
||||
use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
trait AddTrait
|
||||
{
|
||||
/**
|
||||
* @var RouteCollection
|
||||
*/
|
||||
private $collection;
|
||||
|
||||
private $name = '';
|
||||
|
||||
/**
|
||||
* Adds a route.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
*
|
||||
* @return RouteConfigurator
|
||||
*/
|
||||
final public function add($name, $path)
|
||||
{
|
||||
$parentConfigurator = $this instanceof RouteConfigurator ? $this->parentConfigurator : null;
|
||||
$this->collection->add($this->name.$name, $route = new Route($path));
|
||||
|
||||
return new RouteConfigurator($this->collection, $route, '', $parentConfigurator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
*
|
||||
* @return RouteConfigurator
|
||||
*/
|
||||
final public function __invoke($name, $path)
|
||||
{
|
||||
return $this->add($name, $path);
|
||||
}
|
||||
}
|
131
vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php
vendored
Normal file
131
vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator\Traits;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
trait RouteTrait
|
||||
{
|
||||
/**
|
||||
* @var RouteCollection|Route
|
||||
*/
|
||||
private $route;
|
||||
|
||||
/**
|
||||
* Adds defaults.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function defaults(array $defaults)
|
||||
{
|
||||
$this->route->addDefaults($defaults);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds requirements.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function requirements(array $requirements)
|
||||
{
|
||||
$this->route->addRequirements($requirements);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds options.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function options(array $options)
|
||||
{
|
||||
$this->route->addOptions($options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the condition.
|
||||
*
|
||||
* @param string $condition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function condition($condition)
|
||||
{
|
||||
$this->route->setCondition($condition);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pattern for the host.
|
||||
*
|
||||
* @param string $pattern
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function host($pattern)
|
||||
{
|
||||
$this->route->setHost($pattern);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the schemes (e.g. 'https') this route is restricted to.
|
||||
* So an empty array means that any scheme is allowed.
|
||||
*
|
||||
* @param string[] $schemes
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function schemes(array $schemes)
|
||||
{
|
||||
$this->route->setSchemes($schemes);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTTP methods (e.g. 'POST') this route is restricted to.
|
||||
* So an empty array means that any method is allowed.
|
||||
*
|
||||
* @param string[] $methods
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function methods(array $methods)
|
||||
{
|
||||
$this->route->setMethods($methods);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the "_controller" entry to defaults.
|
||||
*
|
||||
* @param callable|string $controller a callable or parseable pseudo-callable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function controller($controller)
|
||||
{
|
||||
$this->route->addDefaults(array('_controller' => $controller));
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\Routing\Loader\ObjectRouteLoader;
|
||||
|
||||
/**
|
||||
|
@@ -12,8 +12,8 @@
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class DirectoryLoader extends FileLoader
|
||||
{
|
||||
|
47
vendor/symfony/routing/Loader/GlobFileLoader.php
vendored
Normal file
47
vendor/symfony/routing/Loader/GlobFileLoader.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* GlobFileLoader loads files from a glob pattern.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class GlobFileLoader extends FileLoader
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
|
||||
foreach ($this->glob($resource, false, $globResource) as $path => $info) {
|
||||
$collection->addCollection($this->import($path));
|
||||
}
|
||||
|
||||
$collection->addResource($globResource);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return 'glob' === $type;
|
||||
}
|
||||
}
|
@@ -45,7 +45,7 @@ abstract class ObjectRouteLoader extends Loader
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
$parts = explode(':', $resource);
|
||||
if (count($parts) != 2) {
|
||||
if (2 != \count($parts)) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service_name:methodName"', $resource));
|
||||
}
|
||||
|
||||
@@ -54,20 +54,20 @@ abstract class ObjectRouteLoader extends Loader
|
||||
|
||||
$loaderObject = $this->getServiceObject($serviceString);
|
||||
|
||||
if (!is_object($loaderObject)) {
|
||||
throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', get_class($this), gettype($loaderObject)));
|
||||
if (!\is_object($loaderObject)) {
|
||||
throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
|
||||
}
|
||||
|
||||
if (!method_exists($loaderObject, $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, get_class($loaderObject), $resource));
|
||||
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
|
||||
}
|
||||
|
||||
$routeCollection = call_user_func(array($loaderObject, $method), $this);
|
||||
$routeCollection = \call_user_func(array($loaderObject, $method), $this);
|
||||
|
||||
if (!$routeCollection instanceof RouteCollection) {
|
||||
$type = is_object($routeCollection) ? get_class($routeCollection) : gettype($routeCollection);
|
||||
$type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection);
|
||||
|
||||
throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', get_class($loaderObject), $method, $type));
|
||||
throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', \get_class($loaderObject), $method, $type));
|
||||
}
|
||||
|
||||
// make the service file tracked so that if it changes, the cache rebuilds
|
||||
|
41
vendor/symfony/routing/Loader/PhpFileLoader.php
vendored
41
vendor/symfony/routing/Loader/PhpFileLoader.php
vendored
@@ -13,6 +13,7 @@ namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
@@ -35,9 +36,23 @@ class PhpFileLoader extends FileLoader
|
||||
public function load($file, $type = null)
|
||||
{
|
||||
$path = $this->locator->locate($file);
|
||||
$this->setCurrentDir(dirname($path));
|
||||
$this->setCurrentDir(\dirname($path));
|
||||
|
||||
// the closure forbids access to the private scope in the included file
|
||||
$loader = $this;
|
||||
$load = \Closure::bind(function ($file) use ($loader) {
|
||||
return include $file;
|
||||
}, null, ProtectedPhpFileLoader::class);
|
||||
|
||||
$result = $load($path);
|
||||
|
||||
if ($result instanceof \Closure) {
|
||||
$collection = new RouteCollection();
|
||||
$result(new RoutingConfigurator($collection, $this, $path, $file), $this);
|
||||
} else {
|
||||
$collection = $result;
|
||||
}
|
||||
|
||||
$collection = self::includeFile($path, $this);
|
||||
$collection->addResource(new FileResource($path));
|
||||
|
||||
return $collection;
|
||||
@@ -48,19 +63,13 @@ class PhpFileLoader extends FileLoader
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe include. Used for scope isolation.
|
||||
*
|
||||
* @param string $file File to include
|
||||
* @param PhpFileLoader $loader the loader variable is exposed to the included file below
|
||||
*
|
||||
* @return RouteCollection
|
||||
*/
|
||||
private static function includeFile($file, PhpFileLoader $loader)
|
||||
{
|
||||
return include $file;
|
||||
return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ProtectedPhpFileLoader extends PhpFileLoader
|
||||
{
|
||||
}
|
||||
|
174
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
174
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
@@ -11,11 +11,11 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* XmlFileLoader loads XML routing files.
|
||||
@@ -36,8 +36,8 @@ class XmlFileLoader extends FileLoader
|
||||
*
|
||||
* @return RouteCollection A RouteCollection instance
|
||||
*
|
||||
* @throws \InvalidArgumentException When the file cannot be loaded or when the XML cannot be
|
||||
* parsed because it does not validate against the scheme.
|
||||
* @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be
|
||||
* parsed because it does not validate against the scheme
|
||||
*/
|
||||
public function load($file, $type = null)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ class XmlFileLoader extends FileLoader
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
|
||||
return \is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,28 +144,35 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path);
|
||||
|
||||
$this->setCurrentDir(dirname($path));
|
||||
$this->setCurrentDir(\dirname($path));
|
||||
|
||||
$subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file);
|
||||
/* @var $subCollection RouteCollection */
|
||||
$subCollection->addPrefix($prefix);
|
||||
if (null !== $host) {
|
||||
$subCollection->setHost($host);
|
||||
}
|
||||
if (null !== $condition) {
|
||||
$subCollection->setCondition($condition);
|
||||
}
|
||||
if (null !== $schemes) {
|
||||
$subCollection->setSchemes($schemes);
|
||||
}
|
||||
if (null !== $methods) {
|
||||
$subCollection->setMethods($methods);
|
||||
}
|
||||
$subCollection->addDefaults($defaults);
|
||||
$subCollection->addRequirements($requirements);
|
||||
$subCollection->addOptions($options);
|
||||
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
|
||||
|
||||
$collection->addCollection($subCollection);
|
||||
if (!\is_array($imported)) {
|
||||
$imported = array($imported);
|
||||
}
|
||||
|
||||
foreach ($imported as $subCollection) {
|
||||
/* @var $subCollection RouteCollection */
|
||||
$subCollection->addPrefix($prefix);
|
||||
if (null !== $host) {
|
||||
$subCollection->setHost($host);
|
||||
}
|
||||
if (null !== $condition) {
|
||||
$subCollection->setCondition($condition);
|
||||
}
|
||||
if (null !== $schemes) {
|
||||
$subCollection->setSchemes($schemes);
|
||||
}
|
||||
if (null !== $methods) {
|
||||
$subCollection->setMethods($methods);
|
||||
}
|
||||
$subCollection->addDefaults($defaults);
|
||||
$subCollection->addRequirements($requirements);
|
||||
$subCollection->addOptions($options);
|
||||
|
||||
$collection->addCollection($subCollection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,12 +209,16 @@ class XmlFileLoader extends FileLoader
|
||||
$condition = null;
|
||||
|
||||
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
|
||||
if ($node !== $n->parentNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ($n->localName) {
|
||||
case 'default':
|
||||
if ($this->isElementValueNull($n)) {
|
||||
$defaults[$n->getAttribute('key')] = null;
|
||||
} else {
|
||||
$defaults[$n->getAttribute('key')] = trim($n->textContent);
|
||||
$defaults[$n->getAttribute('key')] = $this->parseDefaultsConfig($n, $path);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -221,13 +232,120 @@ class XmlFileLoader extends FileLoader
|
||||
$condition = trim($n->textContent);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "default", "requirement" or "option".', $n->localName, $path));
|
||||
throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "default", "requirement", "option" or "condition".', $n->localName, $path));
|
||||
}
|
||||
}
|
||||
|
||||
if ($controller = $node->getAttribute('controller')) {
|
||||
if (isset($defaults['_controller'])) {
|
||||
$name = $node->hasAttribute('id') ? sprintf('"%s"', $node->getAttribute('id')) : sprintf('the "%s" tag', $node->tagName);
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" attribute and the defaults key "_controller" for %s.', $path, $name));
|
||||
}
|
||||
|
||||
$defaults['_controller'] = $controller;
|
||||
}
|
||||
|
||||
return array($defaults, $requirements, $options, $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the "default" elements.
|
||||
*
|
||||
* @param \DOMElement $element The "default" element to parse
|
||||
* @param string $path Full path of the XML file being processed
|
||||
*
|
||||
* @return array|bool|float|int|string|null The parsed value of the "default" element
|
||||
*/
|
||||
private function parseDefaultsConfig(\DOMElement $element, $path)
|
||||
{
|
||||
if ($this->isElementValueNull($element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for existing element nodes in the default element. There can
|
||||
// only be a single element inside a default element. So this element
|
||||
// (if one was found) can safely be returned.
|
||||
foreach ($element->childNodes as $child) {
|
||||
if (!$child instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (self::NAMESPACE_URI !== $child->namespaceURI) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $this->parseDefaultNode($child, $path);
|
||||
}
|
||||
|
||||
// If the default element doesn't contain a nested "bool", "int", "float",
|
||||
// "string", "list", or "map" element, the element contents will be treated
|
||||
// as the string value of the associated default option.
|
||||
return trim($element->textContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively parses the value of a "default" element.
|
||||
*
|
||||
* @param \DOMElement $node The node value
|
||||
* @param string $path Full path of the XML file being processed
|
||||
*
|
||||
* @return array|bool|float|int|string The parsed value
|
||||
*
|
||||
* @throws \InvalidArgumentException when the XML is invalid
|
||||
*/
|
||||
private function parseDefaultNode(\DOMElement $node, $path)
|
||||
{
|
||||
if ($this->isElementValueNull($node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($node->localName) {
|
||||
case 'bool':
|
||||
return 'true' === trim($node->nodeValue) || '1' === trim($node->nodeValue);
|
||||
case 'int':
|
||||
return (int) trim($node->nodeValue);
|
||||
case 'float':
|
||||
return (float) trim($node->nodeValue);
|
||||
case 'string':
|
||||
return trim($node->nodeValue);
|
||||
case 'list':
|
||||
$list = array();
|
||||
|
||||
foreach ($node->childNodes as $element) {
|
||||
if (!$element instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (self::NAMESPACE_URI !== $element->namespaceURI) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$list[] = $this->parseDefaultNode($element, $path);
|
||||
}
|
||||
|
||||
return $list;
|
||||
case 'map':
|
||||
$map = array();
|
||||
|
||||
foreach ($node->childNodes as $element) {
|
||||
if (!$element instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (self::NAMESPACE_URI !== $element->namespaceURI) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$map[$element->getAttribute('key')] = $this->parseDefaultNode($element, $path);
|
||||
}
|
||||
|
||||
return $map;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "bool", "int", "float", "string", "list", or "map".', $node->localName, $path));
|
||||
}
|
||||
}
|
||||
|
||||
private function isElementValueNull(\DOMElement $element)
|
||||
{
|
||||
$namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance';
|
||||
|
82
vendor/symfony/routing/Loader/YamlFileLoader.php
vendored
82
vendor/symfony/routing/Loader/YamlFileLoader.php
vendored
@@ -11,12 +11,12 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
|
||||
/**
|
||||
* YamlFileLoader loads Yaml routing files.
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Config\Loader\FileLoader;
|
||||
class YamlFileLoader extends FileLoader
|
||||
{
|
||||
private static $availableKeys = array(
|
||||
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition',
|
||||
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller',
|
||||
);
|
||||
private $yamlParser;
|
||||
|
||||
@@ -57,10 +57,18 @@ class YamlFileLoader extends FileLoader
|
||||
$this->yamlParser = new YamlParser();
|
||||
}
|
||||
|
||||
$prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($file, &$prevErrorHandler) {
|
||||
$message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message;
|
||||
|
||||
return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false;
|
||||
});
|
||||
|
||||
try {
|
||||
$parsedConfig = $this->yamlParser->parse(file_get_contents($path));
|
||||
$parsedConfig = $this->yamlParser->parseFile($path);
|
||||
} catch (ParseException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
$collection = new RouteCollection();
|
||||
@@ -72,7 +80,7 @@ class YamlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
// not an array
|
||||
if (!is_array($parsedConfig)) {
|
||||
if (!\is_array($parsedConfig)) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path));
|
||||
}
|
||||
|
||||
@@ -94,7 +102,7 @@ class YamlFileLoader extends FileLoader
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type);
|
||||
return \is_string($resource) && \in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,6 +123,10 @@ class YamlFileLoader extends FileLoader
|
||||
$methods = isset($config['methods']) ? $config['methods'] : array();
|
||||
$condition = isset($config['condition']) ? $config['condition'] : null;
|
||||
|
||||
if (isset($config['controller'])) {
|
||||
$defaults['_controller'] = $config['controller'];
|
||||
}
|
||||
|
||||
$route = new Route($config['path'], $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
|
||||
|
||||
$collection->add($name, $route);
|
||||
@@ -140,28 +152,39 @@ class YamlFileLoader extends FileLoader
|
||||
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
|
||||
$methods = isset($config['methods']) ? $config['methods'] : null;
|
||||
|
||||
$this->setCurrentDir(dirname($path));
|
||||
if (isset($config['controller'])) {
|
||||
$defaults['_controller'] = $config['controller'];
|
||||
}
|
||||
|
||||
$subCollection = $this->import($config['resource'], $type, false, $file);
|
||||
/* @var $subCollection RouteCollection */
|
||||
$subCollection->addPrefix($prefix);
|
||||
if (null !== $host) {
|
||||
$subCollection->setHost($host);
|
||||
}
|
||||
if (null !== $condition) {
|
||||
$subCollection->setCondition($condition);
|
||||
}
|
||||
if (null !== $schemes) {
|
||||
$subCollection->setSchemes($schemes);
|
||||
}
|
||||
if (null !== $methods) {
|
||||
$subCollection->setMethods($methods);
|
||||
}
|
||||
$subCollection->addDefaults($defaults);
|
||||
$subCollection->addRequirements($requirements);
|
||||
$subCollection->addOptions($options);
|
||||
$this->setCurrentDir(\dirname($path));
|
||||
|
||||
$collection->addCollection($subCollection);
|
||||
$imported = $this->import($config['resource'], $type, false, $file);
|
||||
|
||||
if (!\is_array($imported)) {
|
||||
$imported = array($imported);
|
||||
}
|
||||
|
||||
foreach ($imported as $subCollection) {
|
||||
/* @var $subCollection RouteCollection */
|
||||
$subCollection->addPrefix($prefix);
|
||||
if (null !== $host) {
|
||||
$subCollection->setHost($host);
|
||||
}
|
||||
if (null !== $condition) {
|
||||
$subCollection->setCondition($condition);
|
||||
}
|
||||
if (null !== $schemes) {
|
||||
$subCollection->setSchemes($schemes);
|
||||
}
|
||||
if (null !== $methods) {
|
||||
$subCollection->setMethods($methods);
|
||||
}
|
||||
$subCollection->addDefaults($defaults);
|
||||
$subCollection->addRequirements($requirements);
|
||||
$subCollection->addOptions($options);
|
||||
|
||||
$collection->addCollection($subCollection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +199,7 @@ class YamlFileLoader extends FileLoader
|
||||
*/
|
||||
protected function validate($config, $name, $path)
|
||||
{
|
||||
if (!is_array($config)) {
|
||||
if (!\is_array($config)) {
|
||||
throw new \InvalidArgumentException(sprintf('The definition of "%s" in "%s" must be a YAML array.', $name, $path));
|
||||
}
|
||||
if ($extraKeys = array_diff(array_keys($config), self::$availableKeys)) {
|
||||
@@ -203,5 +226,8 @@ class YamlFileLoader extends FileLoader
|
||||
$name, $path
|
||||
));
|
||||
}
|
||||
if (isset($config['controller']) && isset($config['defaults']['_controller'])) {
|
||||
throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" key and the defaults key "_controller" for "%s".', $path, $name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
<xsd:group name="configs">
|
||||
<xsd:choice>
|
||||
<xsd:element name="default" nillable="true" type="element" />
|
||||
<xsd:element name="default" nillable="true" type="default" />
|
||||
<xsd:element name="requirement" type="element" />
|
||||
<xsd:element name="option" type="element" />
|
||||
<xsd:element name="condition" type="xsd:string" />
|
||||
@@ -41,6 +41,7 @@
|
||||
<xsd:attribute name="host" type="xsd:string" />
|
||||
<xsd:attribute name="schemes" type="xsd:string" />
|
||||
<xsd:attribute name="methods" type="xsd:string" />
|
||||
<xsd:attribute name="controller" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="import">
|
||||
@@ -52,6 +53,19 @@
|
||||
<xsd:attribute name="host" type="xsd:string" />
|
||||
<xsd:attribute name="schemes" type="xsd:string" />
|
||||
<xsd:attribute name="methods" type="xsd:string" />
|
||||
<xsd:attribute name="controller" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="default" mixed="true">
|
||||
<xsd:choice minOccurs="0" maxOccurs="1">
|
||||
<xsd:element name="bool" type="xsd:boolean" />
|
||||
<xsd:element name="int" type="xsd:integer" />
|
||||
<xsd:element name="float" type="xsd:float" />
|
||||
<xsd:element name="string" type="xsd:string" />
|
||||
<xsd:element name="list" type="list" />
|
||||
<xsd:element name="map" type="map" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="key" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="element">
|
||||
@@ -61,4 +75,74 @@
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="list">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="bool" nillable="true" type="xsd:boolean" />
|
||||
<xsd:element name="int" nillable="true" type="xsd:integer" />
|
||||
<xsd:element name="float" nillable="true" type="xsd:float" />
|
||||
<xsd:element name="string" nillable="true" type="xsd:string" />
|
||||
<xsd:element name="list" nillable="true" type="list" />
|
||||
<xsd:element name="map" nillable="true" type="map" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="map">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="bool" nillable="true" type="map-bool-entry" />
|
||||
<xsd:element name="int" nillable="true" type="map-int-entry" />
|
||||
<xsd:element name="float" nillable="true" type="map-float-entry" />
|
||||
<xsd:element name="string" nillable="true" type="map-string-entry" />
|
||||
<xsd:element name="list" nillable="true" type="map-list-entry" />
|
||||
<xsd:element name="map" nillable="true" type="map-map-entry" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="map-bool-entry">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:boolean">
|
||||
<xsd:attribute name="key" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="map-int-entry">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:integer">
|
||||
<xsd:attribute name="key" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="map-float-entry">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:float">
|
||||
<xsd:attribute name="key" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="map-string-entry">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute name="key" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="map-list-entry">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="list">
|
||||
<xsd:attribute name="key" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="map-map-entry">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="map">
|
||||
<xsd:attribute name="key" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:schema>
|
||||
|
@@ -38,7 +38,7 @@ class DumperCollection implements \IteratorAggregate
|
||||
/**
|
||||
* Returns the children routes and collections.
|
||||
*
|
||||
* @return DumperCollection[]|DumperRoute[] Array of DumperCollection|DumperRoute
|
||||
* @return self[]|DumperRoute[]
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
@@ -86,7 +86,7 @@ class DumperCollection implements \IteratorAggregate
|
||||
/**
|
||||
* Returns the root of the collection.
|
||||
*
|
||||
* @return DumperCollection The root collection
|
||||
* @return self The root collection
|
||||
*/
|
||||
public function getRoot()
|
||||
{
|
||||
@@ -96,7 +96,7 @@ class DumperCollection implements \IteratorAggregate
|
||||
/**
|
||||
* Returns the parent collection.
|
||||
*
|
||||
* @return DumperCollection|null The parent collection or null if the collection has no parent
|
||||
* @return self|null The parent collection or null if the collection has no parent
|
||||
*/
|
||||
protected function getParent()
|
||||
{
|
||||
@@ -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;
|
||||
}
|
||||
|
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Matcher\Dumper;
|
||||
|
||||
/**
|
||||
* Prefix tree of routes preserving routes order.
|
||||
*
|
||||
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DumperPrefixCollection extends DumperCollection
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $prefix = '';
|
||||
|
||||
/**
|
||||
* Returns the prefix.
|
||||
*
|
||||
* @return string The prefix
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
*/
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route in the tree.
|
||||
*
|
||||
* @param DumperRoute $route The route
|
||||
*
|
||||
* @return DumperPrefixCollection The node the route was added to
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function addPrefixRoute(DumperRoute $route)
|
||||
{
|
||||
$prefix = $route->getRoute()->compile()->getStaticPrefix();
|
||||
|
||||
for ($collection = $this; null !== $collection; $collection = $collection->getParent()) {
|
||||
// Same prefix, add to current leave
|
||||
if ($collection->prefix === $prefix) {
|
||||
$collection->add($route);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
// Prefix starts with route's prefix
|
||||
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
|
||||
$child = new self();
|
||||
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix) + 1));
|
||||
$collection->add($child);
|
||||
|
||||
return $child->addPrefixRoute($route);
|
||||
}
|
||||
}
|
||||
|
||||
// Reached only if the root has a non empty prefix
|
||||
throw new \LogicException('The collection root must not have a prefix');
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges nodes whose prefix ends with a slash.
|
||||
*
|
||||
* Children of a node whose prefix ends with a slash are moved to the parent node
|
||||
*/
|
||||
public function mergeSlashNodes()
|
||||
{
|
||||
$children = array();
|
||||
|
||||
foreach ($this as $child) {
|
||||
if ($child instanceof self) {
|
||||
$child->mergeSlashNodes();
|
||||
if ('/' === substr($child->prefix, -1)) {
|
||||
$children = array_merge($children, $child->all());
|
||||
} else {
|
||||
$children[] = $child;
|
||||
}
|
||||
} else {
|
||||
$children[] = $child;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setAll($children);
|
||||
}
|
||||
}
|
@@ -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
|
||||
*/
|
||||
|
@@ -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;
|
||||
|
@@ -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,12 +96,18 @@ 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();
|
||||
|
||||
if ('HEAD' === \$requestMethod) {
|
||||
\$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
$code
|
||||
|
||||
@@ -126,22 +127,21 @@ EOF;
|
||||
private function compileRoutes(RouteCollection $routes, $supportsRedirections)
|
||||
{
|
||||
$fetchedHost = false;
|
||||
|
||||
$groups = $this->groupRoutesByHostRegex($routes);
|
||||
$code = '';
|
||||
|
||||
foreach ($groups as $collection) {
|
||||
if (null !== $regex = $collection->getAttribute('host_regex')) {
|
||||
if (!$fetchedHost) {
|
||||
$code .= " \$host = \$this->context->getHost();\n\n";
|
||||
$code .= " \$host = \$context->getHost();\n\n";
|
||||
$fetchedHost = true;
|
||||
}
|
||||
|
||||
$code .= sprintf(" if (preg_match(%s, \$host, \$hostMatches)) {\n", var_export($regex, true));
|
||||
}
|
||||
|
||||
$tree = $this->buildPrefixTree($collection);
|
||||
$groupCode = $this->compilePrefixRoutes($tree, $supportsRedirections);
|
||||
$tree = $this->buildStaticPrefixCollection($collection);
|
||||
$groupCode = $this->compileStaticPrefixRoutes($tree, $supportsRedirections);
|
||||
|
||||
if (null !== $regex) {
|
||||
// apply extra indention at each line (except empty ones)
|
||||
@@ -153,40 +153,59 @@ 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;
|
||||
}
|
||||
|
||||
private function buildStaticPrefixCollection(DumperCollection $collection)
|
||||
{
|
||||
$prefixCollection = new StaticPrefixCollection();
|
||||
|
||||
foreach ($collection as $dumperRoute) {
|
||||
$prefix = $dumperRoute->getRoute()->compile()->getStaticPrefix();
|
||||
$prefixCollection->addRoute($prefix, $dumperRoute);
|
||||
}
|
||||
|
||||
$prefixCollection->optimizeGroups();
|
||||
|
||||
return $prefixCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates PHP code recursively to match a tree of routes.
|
||||
* Generates PHP code to match a tree of routes.
|
||||
*
|
||||
* @param DumperPrefixCollection $collection A DumperPrefixCollection instance
|
||||
* @param StaticPrefixCollection $collection A StaticPrefixCollection instance
|
||||
* @param bool $supportsRedirections Whether redirections are supported by the base class
|
||||
* @param string $parentPrefix Prefix of the parent collection
|
||||
* @param string $ifOrElseIf either "if" or "elseif" to influence chaining
|
||||
*
|
||||
* @return string PHP code
|
||||
*/
|
||||
private function compilePrefixRoutes(DumperPrefixCollection $collection, $supportsRedirections, $parentPrefix = '')
|
||||
private function compileStaticPrefixRoutes(StaticPrefixCollection $collection, $supportsRedirections, $ifOrElseIf = 'if')
|
||||
{
|
||||
$code = '';
|
||||
$prefix = $collection->getPrefix();
|
||||
$optimizable = 1 < strlen($prefix) && 1 < count($collection->all());
|
||||
$optimizedPrefix = $parentPrefix;
|
||||
|
||||
if ($optimizable) {
|
||||
$optimizedPrefix = $prefix;
|
||||
|
||||
$code .= sprintf(" if (0 === strpos(\$pathinfo, %s)) {\n", var_export($prefix, true));
|
||||
if (!empty($prefix) && '/' !== $prefix) {
|
||||
$code .= sprintf(" %s (0 === strpos(\$pathinfo, %s)) {\n", $ifOrElseIf, var_export($prefix, true));
|
||||
}
|
||||
|
||||
foreach ($collection as $route) {
|
||||
if ($route instanceof DumperCollection) {
|
||||
$code .= $this->compilePrefixRoutes($route, $supportsRedirections, $optimizedPrefix);
|
||||
$ifOrElseIf = 'if';
|
||||
|
||||
foreach ($collection->getItems() as $route) {
|
||||
if ($route instanceof StaticPrefixCollection) {
|
||||
$code .= $this->compileStaticPrefixRoutes($route, $supportsRedirections, $ifOrElseIf);
|
||||
$ifOrElseIf = 'elseif';
|
||||
} else {
|
||||
$code .= $this->compileRoute($route->getRoute(), $route->getName(), $supportsRedirections, $optimizedPrefix)."\n";
|
||||
$code .= $this->compileRoute($route[1]->getRoute(), $route[1]->getName(), $supportsRedirections, $prefix)."\n";
|
||||
$ifOrElseIf = 'if';
|
||||
}
|
||||
}
|
||||
|
||||
if ($optimizable) {
|
||||
if (!empty($prefix) && '/' !== $prefix) {
|
||||
$code .= " }\n\n";
|
||||
// apply extra indention at each line (except empty ones)
|
||||
$code = preg_replace('/^.{2,}$/m', ' $0', $code);
|
||||
@@ -217,26 +236,21 @@ EOF;
|
||||
$hostMatches = false;
|
||||
$methods = $route->getMethods();
|
||||
|
||||
// GET and HEAD are equivalent
|
||||
if (in_array('GET', $methods) && !in_array('HEAD', $methods)) {
|
||||
$methods[] = 'HEAD';
|
||||
}
|
||||
$supportsTrailingSlash = $supportsRedirections && (!$methods || \in_array('GET', $methods));
|
||||
$regex = $compiledRoute->getRegex();
|
||||
|
||||
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods));
|
||||
|
||||
if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
|
||||
if ($supportsTrailingSlash && substr($m['url'], -1) === '/') {
|
||||
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
|
||||
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 {
|
||||
$conditions[] = sprintf('$pathinfo === %s', var_export(str_replace('\\', '', $m['url']), true));
|
||||
$conditions[] = sprintf('%s === $pathinfo', var_export(str_replace('\\', '', $m['url']), true));
|
||||
}
|
||||
} else {
|
||||
if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) {
|
||||
$conditions[] = sprintf('0 === strpos($pathinfo, %s)', var_export($compiledRoute->getStaticPrefix(), true));
|
||||
}
|
||||
|
||||
$regex = $compiledRoute->getRegex();
|
||||
if ($supportsTrailingSlash && $pos = strpos($regex, '/$')) {
|
||||
$regex = substr($regex, 0, $pos).'/?$'.substr($regex, $pos + 2);
|
||||
$hasTrailingSlash = true;
|
||||
@@ -263,53 +277,9 @@ EOF;
|
||||
EOF;
|
||||
|
||||
$gotoname = 'not_'.preg_replace('/[^A-Za-z0-9_]/', '', $name);
|
||||
if ($methods) {
|
||||
if (1 === count($methods)) {
|
||||
$code .= <<<EOF
|
||||
if (\$this->context->getMethod() != '$methods[0]') {
|
||||
\$allow[] = '$methods[0]';
|
||||
goto $gotoname;
|
||||
}
|
||||
|
||||
|
||||
EOF;
|
||||
} else {
|
||||
$methods = implode("', '", $methods);
|
||||
$code .= <<<EOF
|
||||
if (!in_array(\$this->context->getMethod(), 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[\$this->context->getScheme()])) {
|
||||
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) {
|
||||
@@ -323,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";
|
||||
}
|
||||
|
||||
@@ -353,7 +398,6 @@ EOF;
|
||||
private function groupRoutesByHostRegex(RouteCollection $routes)
|
||||
{
|
||||
$groups = new DumperCollection();
|
||||
|
||||
$currentGroup = new DumperCollection();
|
||||
$currentGroup->setAttribute('host_regex', null);
|
||||
$groups->add($currentGroup);
|
||||
@@ -371,30 +415,6 @@ EOF;
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Organizes the routes into a prefix tree.
|
||||
*
|
||||
* Routes order is preserved such that traversing the tree will traverse the
|
||||
* routes in the origin order.
|
||||
*
|
||||
* @param DumperCollection $collection A collection of routes
|
||||
*
|
||||
* @return DumperPrefixCollection
|
||||
*/
|
||||
private function buildPrefixTree(DumperCollection $collection)
|
||||
{
|
||||
$tree = new DumperPrefixCollection();
|
||||
$current = $tree;
|
||||
|
||||
foreach ($collection as $route) {
|
||||
$current = $current->addPrefixRoute($route);
|
||||
}
|
||||
|
||||
$tree->mergeSlashNodes();
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
private function getExpressionLanguage()
|
||||
{
|
||||
if (null === $this->expressionLanguage) {
|
||||
|
238
vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php
vendored
Normal file
238
vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Matcher\Dumper;
|
||||
|
||||
/**
|
||||
* Prefix tree of routes preserving routes order.
|
||||
*
|
||||
* @author Frank de Jonge <info@frankdejonge.nl>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class StaticPrefixCollection
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* @var array[]|StaticPrefixCollection[]
|
||||
*/
|
||||
private $items = array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $matchStart = 0;
|
||||
|
||||
public function __construct($prefix = '')
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]|StaticPrefixCollection[]
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to a group.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param mixed $route
|
||||
*/
|
||||
public function addRoute($prefix, $route)
|
||||
{
|
||||
$prefix = '/' === $prefix ? $prefix : rtrim($prefix, '/');
|
||||
$this->guardAgainstAddingNotAcceptedRoutes($prefix);
|
||||
|
||||
if ($this->prefix === $prefix) {
|
||||
// When a prefix is exactly the same as the base we move up the match start position.
|
||||
// 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);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->items as $i => $item) {
|
||||
if ($i < $this->matchStart) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($item instanceof self && $item->accepts($prefix)) {
|
||||
$item->addRoute($prefix, $route);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$group = $this->groupWithItem($item, $prefix, $route);
|
||||
|
||||
if ($group instanceof self) {
|
||||
$this->items[$i] = $group;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// No optimised case was found, in this case we simple add the route for possible
|
||||
// grouping when new routes are added.
|
||||
$this->items[] = array($prefix, $route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to combine a route with another route or group.
|
||||
*
|
||||
* @param StaticPrefixCollection|array $item
|
||||
* @param string $prefix
|
||||
* @param mixed $route
|
||||
*
|
||||
* @return null|StaticPrefixCollection
|
||||
*/
|
||||
private function groupWithItem($item, $prefix, $route)
|
||||
{
|
||||
$itemPrefix = $item instanceof self ? $item->prefix : $item[0];
|
||||
$commonPrefix = $this->detectCommonPrefix($prefix, $itemPrefix);
|
||||
|
||||
if (!$commonPrefix) {
|
||||
return;
|
||||
}
|
||||
|
||||
$child = new self($commonPrefix);
|
||||
|
||||
if ($item instanceof self) {
|
||||
$child->items = array($item);
|
||||
} else {
|
||||
$child->addRoute($item[0], $item[1]);
|
||||
}
|
||||
|
||||
$child->addRoute($prefix, $route);
|
||||
|
||||
return $child;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a prefix can be contained within the group.
|
||||
*
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return bool Whether a prefix could belong in a given group
|
||||
*/
|
||||
private function accepts($prefix)
|
||||
{
|
||||
return '' === $this->prefix || 0 === strpos($prefix, $this->prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects whether there's a common prefix relative to the group prefix and returns it.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $anotherPrefix
|
||||
*
|
||||
* @return false|string A common prefix, longer than the base/group prefix, or false when none available
|
||||
*/
|
||||
private function detectCommonPrefix($prefix, $anotherPrefix)
|
||||
{
|
||||
$baseLength = \strlen($this->prefix);
|
||||
$commonLength = $baseLength;
|
||||
$end = min(\strlen($prefix), \strlen($anotherPrefix));
|
||||
|
||||
for ($i = $baseLength; $i <= $end; ++$i) {
|
||||
if (substr($prefix, 0, $i) !== substr($anotherPrefix, 0, $i)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$commonLength = $i;
|
||||
}
|
||||
|
||||
$commonPrefix = rtrim(substr($prefix, 0, $commonLength), '/');
|
||||
|
||||
if (\strlen($commonPrefix) > $baseLength) {
|
||||
return $commonPrefix;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes the tree by inlining items from groups with less than 3 items.
|
||||
*/
|
||||
public function optimizeGroups()
|
||||
{
|
||||
$index = -1;
|
||||
|
||||
while (isset($this->items[++$index])) {
|
||||
$item = $this->items[$index];
|
||||
|
||||
if ($item instanceof self) {
|
||||
$item->optimizeGroups();
|
||||
|
||||
// When a group contains only two items there's no reason to optimize because at minimum
|
||||
// the amount of prefix check is 2. In this case inline the group.
|
||||
if ($item->shouldBeInlined()) {
|
||||
array_splice($this->items, $index, 1, $item->items);
|
||||
|
||||
// Lower index to pass through the same index again after optimizing.
|
||||
// The first item of the replacements might be a group needing optimization.
|
||||
--$index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function shouldBeInlined()
|
||||
{
|
||||
if (\count($this->items) >= 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
if ($item instanceof self) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
if (\is_array($item) && $item[0] === $this->prefix) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guards against adding incompatible prefixes in a group.
|
||||
*
|
||||
* @param string $prefix
|
||||
*
|
||||
* @throws \LogicException when a prefix does not belong in a group
|
||||
*/
|
||||
private function guardAgainstAddingNotAcceptedRoutes($prefix)
|
||||
{
|
||||
if (!$this->accepts($prefix)) {
|
||||
$message = sprintf('Could not add route with prefix %s to collection with prefix %s', $prefix, $this->prefix);
|
||||
|
||||
throw new \LogicException($message);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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
vendor/symfony/routing/Matcher/UrlMatcher.php
vendored
77
vendor/symfony/routing/Matcher/UrlMatcher.php
vendored
@@ -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(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
*/
|
||||
|
30
vendor/symfony/routing/RequestContext.php
vendored
30
vendor/symfony/routing/RequestContext.php
vendored
@@ -31,15 +31,9 @@ class RequestContext
|
||||
private $httpPort;
|
||||
private $httpsPort;
|
||||
private $queryString;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $parameters = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $baseUrl The base URL
|
||||
* @param string $method The HTTP method
|
||||
* @param string $host The HTTP host name
|
||||
@@ -64,9 +58,7 @@ class RequestContext
|
||||
/**
|
||||
* Updates the RequestContext information based on a HttpFoundation Request.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function fromRequest(Request $request)
|
||||
{
|
||||
@@ -97,7 +89,7 @@ class RequestContext
|
||||
*
|
||||
* @param string $baseUrl The base URL
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setBaseUrl($baseUrl)
|
||||
{
|
||||
@@ -121,7 +113,7 @@ class RequestContext
|
||||
*
|
||||
* @param string $pathInfo The path info
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setPathInfo($pathInfo)
|
||||
{
|
||||
@@ -147,7 +139,7 @@ class RequestContext
|
||||
*
|
||||
* @param string $method The HTTP method
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setMethod($method)
|
||||
{
|
||||
@@ -173,7 +165,7 @@ class RequestContext
|
||||
*
|
||||
* @param string $host The HTTP host
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setHost($host)
|
||||
{
|
||||
@@ -197,7 +189,7 @@ class RequestContext
|
||||
*
|
||||
* @param string $scheme The HTTP scheme
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setScheme($scheme)
|
||||
{
|
||||
@@ -221,7 +213,7 @@ class RequestContext
|
||||
*
|
||||
* @param int $httpPort The HTTP port
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setHttpPort($httpPort)
|
||||
{
|
||||
@@ -245,7 +237,7 @@ class RequestContext
|
||||
*
|
||||
* @param int $httpsPort The HTTPS port
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setHttpsPort($httpsPort)
|
||||
{
|
||||
@@ -269,7 +261,7 @@ class RequestContext
|
||||
*
|
||||
* @param string $queryString The query string (after "?")
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setQueryString($queryString)
|
||||
{
|
||||
@@ -294,7 +286,7 @@ class RequestContext
|
||||
*
|
||||
* @param array $parameters The parameters
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setParameters(array $parameters)
|
||||
{
|
||||
@@ -333,7 +325,7 @@ class RequestContext
|
||||
* @param string $name A parameter name
|
||||
* @param mixed $parameter The parameter value
|
||||
*
|
||||
* @return RequestContext The current instance, implementing a fluent interface
|
||||
* @return $this
|
||||
*/
|
||||
public function setParameter($name, $parameter)
|
||||
{
|
||||
|
@@ -15,8 +15,6 @@ interface RequestContextAwareInterface
|
||||
{
|
||||
/**
|
||||
* Sets the request context.
|
||||
*
|
||||
* @param RequestContext $context The context
|
||||
*/
|
||||
public function setContext(RequestContext $context);
|
||||
|
||||
|
90
vendor/symfony/routing/Route.php
vendored
90
vendor/symfony/routing/Route.php
vendored
@@ -19,66 +19,36 @@ namespace Symfony\Component\Routing;
|
||||
*/
|
||||
class Route implements \Serializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $path = '/';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $host = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $schemes = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $methods = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $defaults = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $requirements = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $options = array();
|
||||
private $condition = '';
|
||||
|
||||
/**
|
||||
* @var null|CompiledRoute
|
||||
*/
|
||||
private $compiled;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $condition = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Available options:
|
||||
*
|
||||
* * compiler_class: A class name able to compile this route instance (RouteCompiler by default)
|
||||
* * utf8: Whether UTF-8 matching is enforced ot not
|
||||
*
|
||||
* @param string $path The path pattern to match
|
||||
* @param array $defaults An array of default parameter values
|
||||
* @param array $requirements An array of requirements for parameters (regexes)
|
||||
* @param array $options An array of options
|
||||
* @param string $host The host pattern to match
|
||||
* @param string|array $schemes A required URI scheme or an array of restricted schemes
|
||||
* @param string|array $methods A required HTTP method or an array of restricted methods
|
||||
* @param string $condition A condition that should evaluate to true for the route to match
|
||||
* @param string $path The path pattern to match
|
||||
* @param array $defaults An array of default parameter values
|
||||
* @param array $requirements An array of requirements for parameters (regexes)
|
||||
* @param array $options An array of options
|
||||
* @param string $host The host pattern to match
|
||||
* @param string|string[] $schemes A required URI scheme or an array of restricted schemes
|
||||
* @param string|string[] $methods A required HTTP method or an array of restricted methods
|
||||
* @param string $condition A condition that should evaluate to true for the route to match
|
||||
*/
|
||||
public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '')
|
||||
{
|
||||
@@ -149,7 +119,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param string $pattern The path pattern
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setPath($pattern)
|
||||
{
|
||||
@@ -178,7 +148,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param string $pattern The host pattern
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setHost($pattern)
|
||||
{
|
||||
@@ -192,7 +162,7 @@ class Route implements \Serializable
|
||||
* Returns the lowercased schemes this route is restricted to.
|
||||
* So an empty array means that any scheme is allowed.
|
||||
*
|
||||
* @return array The schemes
|
||||
* @return string[] The schemes
|
||||
*/
|
||||
public function getSchemes()
|
||||
{
|
||||
@@ -205,9 +175,9 @@ class Route implements \Serializable
|
||||
*
|
||||
* This method implements a fluent interface.
|
||||
*
|
||||
* @param string|array $schemes The scheme or an array of schemes
|
||||
* @param string|string[] $schemes The scheme or an array of schemes
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setSchemes($schemes)
|
||||
{
|
||||
@@ -226,14 +196,14 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function hasScheme($scheme)
|
||||
{
|
||||
return in_array(strtolower($scheme), $this->schemes, true);
|
||||
return \in_array(strtolower($scheme), $this->schemes, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the uppercased HTTP methods this route is restricted to.
|
||||
* So an empty array means that any method is allowed.
|
||||
*
|
||||
* @return array The methods
|
||||
* @return string[] The methods
|
||||
*/
|
||||
public function getMethods()
|
||||
{
|
||||
@@ -246,9 +216,9 @@ class Route implements \Serializable
|
||||
*
|
||||
* This method implements a fluent interface.
|
||||
*
|
||||
* @param string|array $methods The method or an array of methods
|
||||
* @param string|string[] $methods The method or an array of methods
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setMethods($methods)
|
||||
{
|
||||
@@ -275,7 +245,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param array $options The options
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
@@ -293,7 +263,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param array $options The options
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function addOptions(array $options)
|
||||
{
|
||||
@@ -313,7 +283,7 @@ class Route implements \Serializable
|
||||
* @param string $name An option name
|
||||
* @param mixed $value The option value
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setOption($name, $value)
|
||||
{
|
||||
@@ -364,7 +334,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param array $defaults The defaults
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaults(array $defaults)
|
||||
{
|
||||
@@ -380,7 +350,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param array $defaults The defaults
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaults(array $defaults)
|
||||
{
|
||||
@@ -422,7 +392,7 @@ class Route implements \Serializable
|
||||
* @param string $name A variable name
|
||||
* @param mixed $default The default value
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefault($name, $default)
|
||||
{
|
||||
@@ -449,7 +419,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param array $requirements The requirements
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequirements(array $requirements)
|
||||
{
|
||||
@@ -465,7 +435,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param array $requirements The requirements
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function addRequirements(array $requirements)
|
||||
{
|
||||
@@ -507,7 +477,7 @@ class Route implements \Serializable
|
||||
* @param string $key The key
|
||||
* @param string $regex The regex
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequirement($key, $regex)
|
||||
{
|
||||
@@ -534,7 +504,7 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param string $condition The condition
|
||||
*
|
||||
* @return Route The current Route instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setCondition($condition)
|
||||
{
|
||||
@@ -567,7 +537,7 @@ class Route implements \Serializable
|
||||
|
||||
private function sanitizeRequirement($key, $regex)
|
||||
{
|
||||
if (!is_string($regex)) {
|
||||
if (!\is_string($regex)) {
|
||||
throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key));
|
||||
}
|
||||
|
||||
|
29
vendor/symfony/routing/RouteCollection.php
vendored
29
vendor/symfony/routing/RouteCollection.php
vendored
@@ -63,7 +63,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->routes);
|
||||
return \count($this->routes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Removes a route or an array of routes by name from the collection.
|
||||
*
|
||||
* @param string|array $name The route name or an array of route names
|
||||
* @param string|string[] $name The route name or an array of route names
|
||||
*/
|
||||
public function remove($name)
|
||||
{
|
||||
@@ -116,10 +116,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Adds a route collection at the end of the current set by appending all
|
||||
* routes of the added collection.
|
||||
*
|
||||
* @param RouteCollection $collection A RouteCollection instance
|
||||
*/
|
||||
public function addCollection(RouteCollection $collection)
|
||||
public function addCollection(self $collection)
|
||||
{
|
||||
// we need to remove all routes with the same names first because just replacing them
|
||||
// would not place the new route at the end of the merged array
|
||||
@@ -128,7 +126,9 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
$this->routes[$name] = $route;
|
||||
}
|
||||
|
||||
$this->resources = array_merge($this->resources, $collection->getResources());
|
||||
foreach ($collection->getResources() as $resource) {
|
||||
$this->addResource($resource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +234,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Sets the schemes (e.g. 'https') all child routes are restricted to.
|
||||
*
|
||||
* @param string|array $schemes The scheme or an array of schemes
|
||||
* @param string|string[] $schemes The scheme or an array of schemes
|
||||
*/
|
||||
public function setSchemes($schemes)
|
||||
{
|
||||
@@ -246,7 +246,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Sets the HTTP methods (e.g. 'POST') all child routes are restricted to.
|
||||
*
|
||||
* @param string|array $methods The method or an array of methods
|
||||
* @param string|string[] $methods The method or an array of methods
|
||||
*/
|
||||
public function setMethods($methods)
|
||||
{
|
||||
@@ -262,16 +262,19 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function getResources()
|
||||
{
|
||||
return array_unique($this->resources);
|
||||
return array_values($this->resources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a resource for this collection.
|
||||
*
|
||||
* @param ResourceInterface $resource A resource instance
|
||||
* Adds a resource for this collection. If the resource already exists
|
||||
* it is not added.
|
||||
*/
|
||||
public function addResource(ResourceInterface $resource)
|
||||
{
|
||||
$this->resources[] = $resource;
|
||||
$key = (string) $resource;
|
||||
|
||||
if (!isset($this->resources[$key])) {
|
||||
$this->resources[$key] = $resource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -38,9 +38,6 @@ class RouteCollectionBuilder
|
||||
private $methods;
|
||||
private $resources = array();
|
||||
|
||||
/**
|
||||
* @param LoaderInterface $loader
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader = null)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
@@ -55,23 +52,30 @@ class RouteCollectionBuilder
|
||||
* @param string|null $prefix
|
||||
* @param string $type
|
||||
*
|
||||
* @return RouteCollectionBuilder
|
||||
* @return self
|
||||
*
|
||||
* @throws FileLoaderLoadException
|
||||
*/
|
||||
public function import($resource, $prefix = '/', $type = null)
|
||||
{
|
||||
/** @var RouteCollection $collection */
|
||||
$collection = $this->load($resource, $type);
|
||||
/** @var RouteCollection[] $collection */
|
||||
$collections = $this->load($resource, $type);
|
||||
|
||||
// create a builder from the RouteCollection
|
||||
$builder = $this->createBuilder();
|
||||
foreach ($collection->all() as $name => $route) {
|
||||
$builder->addRoute($route, $name);
|
||||
}
|
||||
|
||||
foreach ($collection->getResources() as $resource) {
|
||||
$builder->addResource($resource);
|
||||
foreach ($collections as $collection) {
|
||||
if (null === $collection) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($collection->all() as $name => $route) {
|
||||
$builder->addRoute($route, $name);
|
||||
}
|
||||
|
||||
foreach ($collection->getResources() as $resource) {
|
||||
$builder->addResource($resource);
|
||||
}
|
||||
}
|
||||
|
||||
// mount into this builder
|
||||
@@ -101,7 +105,7 @@ class RouteCollectionBuilder
|
||||
/**
|
||||
* Returns a RouteCollectionBuilder that can be configured and then added with mount().
|
||||
*
|
||||
* @return RouteCollectionBuilder
|
||||
* @return self
|
||||
*/
|
||||
public function createBuilder()
|
||||
{
|
||||
@@ -114,7 +118,7 @@ class RouteCollectionBuilder
|
||||
* @param string $prefix
|
||||
* @param RouteCollectionBuilder $builder
|
||||
*/
|
||||
public function mount($prefix, RouteCollectionBuilder $builder)
|
||||
public function mount($prefix, self $builder)
|
||||
{
|
||||
$builder->prefix = trim(trim($prefix), '/');
|
||||
$this->routes[] = $builder;
|
||||
@@ -201,7 +205,7 @@ class RouteCollectionBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an opiton that will be added to all embedded routes (unless that
|
||||
* Sets an option that will be added to all embedded routes (unless that
|
||||
* option is already set).
|
||||
*
|
||||
* @param string $key
|
||||
@@ -247,8 +251,6 @@ class RouteCollectionBuilder
|
||||
/**
|
||||
* Adds a resource for this collection.
|
||||
*
|
||||
* @param ResourceInterface $resource
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
private function addResource(ResourceInterface $resource)
|
||||
@@ -311,10 +313,10 @@ class RouteCollectionBuilder
|
||||
|
||||
$routeCollection->addCollection($subCollection);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->resources as $resource) {
|
||||
$routeCollection->addResource($resource);
|
||||
}
|
||||
foreach ($this->resources as $resource) {
|
||||
$routeCollection->addResource($resource);
|
||||
}
|
||||
|
||||
return $routeCollection;
|
||||
@@ -345,7 +347,7 @@ class RouteCollectionBuilder
|
||||
* @param mixed $resource A resource
|
||||
* @param string|null $type The resource type or null if unknown
|
||||
*
|
||||
* @return RouteCollection
|
||||
* @return RouteCollection[]
|
||||
*
|
||||
* @throws FileLoaderLoadException If no loader is found
|
||||
*/
|
||||
@@ -356,17 +358,21 @@ class RouteCollectionBuilder
|
||||
}
|
||||
|
||||
if ($this->loader->supports($resource, $type)) {
|
||||
return $this->loader->load($resource, $type);
|
||||
$collections = $this->loader->load($resource, $type);
|
||||
|
||||
return \is_array($collections) ? $collections : array($collections);
|
||||
}
|
||||
|
||||
if (null === $resolver = $this->loader->getResolver()) {
|
||||
throw new FileLoaderLoadException($resource);
|
||||
throw new FileLoaderLoadException($resource, null, null, null, $type);
|
||||
}
|
||||
|
||||
if (false === $loader = $resolver->resolve($resource, $type)) {
|
||||
throw new FileLoaderLoadException($resource);
|
||||
throw new FileLoaderLoadException($resource, null, null, null, $type);
|
||||
}
|
||||
|
||||
return $loader->load($resource, $type);
|
||||
$collections = $loader->load($resource, $type);
|
||||
|
||||
return \is_array($collections) ? $collections : array($collections);
|
||||
}
|
||||
}
|
||||
|
129
vendor/symfony/routing/RouteCompiler.php
vendored
129
vendor/symfony/routing/RouteCompiler.php
vendored
@@ -28,12 +28,21 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
*/
|
||||
const SEPARATORS = '/,;.:-_~+*=@|';
|
||||
|
||||
/**
|
||||
* The maximum supported length of a PCRE subpattern name
|
||||
* http://pcre.org/current/doc/html/pcre2pattern.html#SEC16.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const VARIABLE_MAXIMUM_LENGTH = 32;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \LogicException If a variable is referenced more than once
|
||||
* @throws \DomainException If a variable name is numeric because PHP raises an error for such
|
||||
* subpatterns in PCRE and thus would break matching, e.g. "(?P<123>.+)".
|
||||
* @throws \InvalidArgumentException if a path variable is named _fragment
|
||||
* @throws \LogicException if a variable is referenced more than once
|
||||
* @throws \DomainException if a variable name starts with a digit or if it is too long to be successfully used as
|
||||
* a PCRE subpattern
|
||||
*/
|
||||
public static function compile(Route $route)
|
||||
{
|
||||
@@ -59,6 +68,13 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$staticPrefix = $result['staticPrefix'];
|
||||
|
||||
$pathVariables = $result['variables'];
|
||||
|
||||
foreach ($pathVariables as $pathParam) {
|
||||
if ('_fragment' === $pathParam) {
|
||||
throw new \InvalidArgumentException(sprintf('Route pattern "%s" cannot contain "_fragment" as a path parameter.', $route->getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
$variables = array_merge($variables, $pathVariables);
|
||||
|
||||
$tokens = $result['tokens'];
|
||||
@@ -83,6 +99,16 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$matches = array();
|
||||
$pos = 0;
|
||||
$defaultSeparator = $isHost ? '.' : '/';
|
||||
$useUtf8 = preg_match('//u', $pattern);
|
||||
$needsUtf8 = $route->getOption('utf8');
|
||||
|
||||
if (!$needsUtf8 && $useUtf8 && preg_match('/[\x80-\xFF]/', $pattern)) {
|
||||
$needsUtf8 = true;
|
||||
@trigger_error(sprintf('Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "%s".', $pattern), E_USER_DEPRECATED);
|
||||
}
|
||||
if (!$useUtf8 && $needsUtf8) {
|
||||
throw new \LogicException(sprintf('Cannot mix UTF-8 requirements with non-UTF-8 pattern "%s".', $pattern));
|
||||
}
|
||||
|
||||
// Match all variables enclosed in "{}" and iterate over them. But we only want to match the innermost variable
|
||||
// in case of nested "{}", e.g. {foo{bar}}. This in ensured because \w does not match "{" or "}" itself.
|
||||
@@ -91,20 +117,34 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$varName = substr($match[0][0], 1, -1);
|
||||
// get all static text preceding the current variable
|
||||
$precedingText = substr($pattern, $pos, $match[0][1] - $pos);
|
||||
$pos = $match[0][1] + strlen($match[0][0]);
|
||||
$precedingChar = strlen($precedingText) > 0 ? substr($precedingText, -1) : '';
|
||||
$pos = $match[0][1] + \strlen($match[0][0]);
|
||||
|
||||
if (!\strlen($precedingText)) {
|
||||
$precedingChar = '';
|
||||
} elseif ($useUtf8) {
|
||||
preg_match('/.$/u', $precedingText, $precedingChar);
|
||||
$precedingChar = $precedingChar[0];
|
||||
} else {
|
||||
$precedingChar = substr($precedingText, -1);
|
||||
}
|
||||
$isSeparator = '' !== $precedingChar && false !== strpos(static::SEPARATORS, $precedingChar);
|
||||
|
||||
if (is_numeric($varName)) {
|
||||
throw new \DomainException(sprintf('Variable name "%s" cannot be numeric in route pattern "%s". Please use a different name.', $varName, $pattern));
|
||||
// A PCRE subpattern name must start with a non-digit. Also a PHP variable cannot start with a digit so the
|
||||
// variable would not be usable as a Controller action argument.
|
||||
if (preg_match('/^\d/', $varName)) {
|
||||
throw new \DomainException(sprintf('Variable name "%s" cannot start with a digit in route pattern "%s". Please use a different name.', $varName, $pattern));
|
||||
}
|
||||
if (in_array($varName, $variables)) {
|
||||
if (\in_array($varName, $variables)) {
|
||||
throw new \LogicException(sprintf('Route pattern "%s" cannot reference variable name "%s" more than once.', $pattern, $varName));
|
||||
}
|
||||
|
||||
if ($isSeparator && strlen($precedingText) > 1) {
|
||||
$tokens[] = array('text', substr($precedingText, 0, -1));
|
||||
} elseif (!$isSeparator && strlen($precedingText) > 0) {
|
||||
if (\strlen($varName) > self::VARIABLE_MAXIMUM_LENGTH) {
|
||||
throw new \DomainException(sprintf('Variable name "%s" cannot be longer than %s characters in route pattern "%s". Please use a shorter name.', $varName, self::VARIABLE_MAXIMUM_LENGTH, $pattern));
|
||||
}
|
||||
|
||||
if ($isSeparator && $precedingText !== $precedingChar) {
|
||||
$tokens[] = array('text', substr($precedingText, 0, -\strlen($precedingChar)));
|
||||
} elseif (!$isSeparator && \strlen($precedingText) > 0) {
|
||||
$tokens[] = array('text', $precedingText);
|
||||
}
|
||||
|
||||
@@ -118,7 +158,7 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
// If {page} would also match the separating dot, {_format} would never match as {page} will eagerly consume everything.
|
||||
// Also even if {_format} was not optional the requirement prevents that {page} matches something that was originally
|
||||
// part of {_format} when generating the URL, e.g. _format = 'mobile.html'.
|
||||
$nextSeparator = self::findNextSeparator($followingPattern);
|
||||
$nextSeparator = self::findNextSeparator($followingPattern, $useUtf8);
|
||||
$regexp = sprintf(
|
||||
'[^%s%s]+',
|
||||
preg_quote($defaultSeparator, self::REGEX_DELIMITER),
|
||||
@@ -132,20 +172,30 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
// directly adjacent, e.g. '/{x}{y}'.
|
||||
$regexp .= '+';
|
||||
}
|
||||
} else {
|
||||
if (!preg_match('//u', $regexp)) {
|
||||
$useUtf8 = false;
|
||||
} elseif (!$needsUtf8 && preg_match('/[\x80-\xFF]|(?<!\\\\)\\\\(?:\\\\\\\\)*+(?-i:X|[pP][\{CLMNPSZ]|x\{[A-Fa-f0-9]{3})/', $regexp)) {
|
||||
$needsUtf8 = true;
|
||||
@trigger_error(sprintf('Using UTF-8 route requirements without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for variable "%s" in pattern "%s".', $varName, $pattern), E_USER_DEPRECATED);
|
||||
}
|
||||
if (!$useUtf8 && $needsUtf8) {
|
||||
throw new \LogicException(sprintf('Cannot mix UTF-8 requirement with non-UTF-8 charset for variable "%s" in pattern "%s".', $varName, $pattern));
|
||||
}
|
||||
}
|
||||
|
||||
$tokens[] = array('variable', $isSeparator ? $precedingChar : '', $regexp, $varName);
|
||||
$variables[] = $varName;
|
||||
}
|
||||
|
||||
if ($pos < strlen($pattern)) {
|
||||
if ($pos < \strlen($pattern)) {
|
||||
$tokens[] = array('text', substr($pattern, $pos));
|
||||
}
|
||||
|
||||
// find the first optional token
|
||||
$firstOptional = PHP_INT_MAX;
|
||||
if (!$isHost) {
|
||||
for ($i = count($tokens) - 1; $i >= 0; --$i) {
|
||||
for ($i = \count($tokens) - 1; $i >= 0; --$i) {
|
||||
$token = $tokens[$i];
|
||||
if ('variable' === $token[0] && $route->hasDefault($token[3])) {
|
||||
$firstOptional = $i;
|
||||
@@ -157,35 +207,72 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
|
||||
// compute the matching regexp
|
||||
$regexp = '';
|
||||
for ($i = 0, $nbToken = count($tokens); $i < $nbToken; ++$i) {
|
||||
for ($i = 0, $nbToken = \count($tokens); $i < $nbToken; ++$i) {
|
||||
$regexp .= self::computeRegexp($tokens, $i, $firstOptional);
|
||||
}
|
||||
$regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'sD'.($isHost ? 'i' : '');
|
||||
|
||||
// enable Utf8 matching if really required
|
||||
if ($needsUtf8) {
|
||||
$regexp .= 'u';
|
||||
for ($i = 0, $nbToken = \count($tokens); $i < $nbToken; ++$i) {
|
||||
if ('variable' === $tokens[$i][0]) {
|
||||
$tokens[$i][] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'staticPrefix' => 'text' === $tokens[0][0] ? $tokens[0][1] : '',
|
||||
'regex' => self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : ''),
|
||||
'staticPrefix' => self::determineStaticPrefix($route, $tokens),
|
||||
'regex' => $regexp,
|
||||
'tokens' => array_reverse($tokens),
|
||||
'variables' => $variables,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the longest static prefix possible for a route.
|
||||
*
|
||||
* @return string The leading static part of a route's path
|
||||
*/
|
||||
private static function determineStaticPrefix(Route $route, array $tokens)
|
||||
{
|
||||
if ('text' !== $tokens[0][0]) {
|
||||
return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1];
|
||||
}
|
||||
|
||||
$prefix = $tokens[0][1];
|
||||
|
||||
if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) {
|
||||
$prefix .= $tokens[1][1];
|
||||
}
|
||||
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next static character in the Route pattern that will serve as a separator.
|
||||
*
|
||||
* @param string $pattern The route pattern
|
||||
* @param bool $useUtf8 Whether the character is encoded in UTF-8 or not
|
||||
*
|
||||
* @return string The next static character that functions as separator (or empty string when none available)
|
||||
*/
|
||||
private static function findNextSeparator($pattern)
|
||||
private static function findNextSeparator($pattern, $useUtf8)
|
||||
{
|
||||
if ('' == $pattern) {
|
||||
// return empty string if pattern is empty or false (false which can be returned by substr)
|
||||
return '';
|
||||
}
|
||||
// first remove all placeholders from the pattern so we can find the next real static character
|
||||
$pattern = preg_replace('#\{\w+\}#', '', $pattern);
|
||||
if ('' === $pattern = preg_replace('#\{\w+\}#', '', $pattern)) {
|
||||
return '';
|
||||
}
|
||||
if ($useUtf8) {
|
||||
preg_match('/^./u', $pattern, $pattern);
|
||||
}
|
||||
|
||||
return isset($pattern[0]) && false !== strpos(static::SEPARATORS, $pattern[0]) ? $pattern[0] : '';
|
||||
return false !== strpos(static::SEPARATORS, $pattern[0]) ? $pattern[0] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +302,7 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
// "?:" means it is non-capturing, i.e. the portion of the subject string that
|
||||
// matched the optional subpattern is not passed back.
|
||||
$regexp = "(?:$regexp";
|
||||
$nbTokens = count($tokens);
|
||||
$nbTokens = \count($tokens);
|
||||
if ($nbTokens - 1 == $index) {
|
||||
// Close the optional subpatterns
|
||||
$regexp .= str_repeat(')?', $nbTokens - $firstOptional - (0 === $firstOptional ? 1 : 0));
|
||||
|
@@ -21,8 +21,6 @@ interface RouteCompilerInterface
|
||||
/**
|
||||
* Compiles the current route instance.
|
||||
*
|
||||
* @param Route $route A Route instance
|
||||
*
|
||||
* @return CompiledRoute A CompiledRoute instance
|
||||
*
|
||||
* @throws \LogicException If the Route cannot be compiled because the
|
||||
|
44
vendor/symfony/routing/Router.php
vendored
44
vendor/symfony/routing/Router.php
vendored
@@ -11,19 +11,19 @@
|
||||
|
||||
namespace Symfony\Component\Routing;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\ConfigCacheInterface;
|
||||
use Symfony\Component\Config\ConfigCacheFactoryInterface;
|
||||
use Symfony\Component\Config\ConfigCacheFactory;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Config\ConfigCacheFactory;
|
||||
use Symfony\Component\Config\ConfigCacheFactoryInterface;
|
||||
use Symfony\Component\Config\ConfigCacheInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\Generator\Dumper\GeneratorDumperInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface;
|
||||
use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
/**
|
||||
* The Router class is an example of the integration of all pieces of the
|
||||
@@ -84,8 +84,6 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
private $expressionLanguageProviders = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoaderInterface $loader A LoaderInterface instance
|
||||
* @param mixed $resource The main resource to load
|
||||
* @param array $options An array of options
|
||||
@@ -106,9 +104,19 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*
|
||||
* Available options:
|
||||
*
|
||||
* * cache_dir: The cache directory (or null to disable caching)
|
||||
* * debug: Whether to enable debugging or not (false by default)
|
||||
* * resource_type: Type hint for the main resource (optional)
|
||||
* * cache_dir: The cache directory (or null to disable caching)
|
||||
* * debug: Whether to enable debugging or not (false by default)
|
||||
* * generator_class: The name of a UrlGeneratorInterface implementation
|
||||
* * generator_base_class: The base class for the dumped generator class
|
||||
* * generator_cache_class: The class name for the dumped generator class
|
||||
* * generator_dumper_class: The name of a GeneratorDumperInterface implementation
|
||||
* * matcher_class: The name of a UrlMatcherInterface implementation
|
||||
* * matcher_base_class: The base class for the dumped matcher class
|
||||
* * matcher_dumper_class: The class name for the dumped matcher class
|
||||
* * matcher_cache_class: The name of a MatcherDumperInterface implementation
|
||||
* * resource_type: Type hint for the main resource (optional)
|
||||
* * strict_requirements: Configure strict requirement checking for generators
|
||||
* implementing ConfigurableRequirementsInterface (default is true)
|
||||
*
|
||||
* @param array $options An array of options
|
||||
*
|
||||
@@ -218,8 +226,6 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
|
||||
/**
|
||||
* Sets the ConfigCache factory to use.
|
||||
*
|
||||
* @param ConfigCacheFactoryInterface $configCacheFactory The factory to use
|
||||
*/
|
||||
public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory)
|
||||
{
|
||||
@@ -296,7 +302,9 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
}
|
||||
);
|
||||
|
||||
require_once $cache->getPath();
|
||||
if (!class_exists($this->options['matcher_cache_class'], false)) {
|
||||
require_once $cache->getPath();
|
||||
}
|
||||
|
||||
return $this->matcher = new $this->options['matcher_cache_class']($this->context);
|
||||
}
|
||||
@@ -328,7 +336,9 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
}
|
||||
);
|
||||
|
||||
require_once $cache->getPath();
|
||||
if (!class_exists($this->options['generator_cache_class'], false)) {
|
||||
require_once $cache->getPath();
|
||||
}
|
||||
|
||||
$this->generator = new $this->options['generator_cache_class']($this->context, $this->logger);
|
||||
}
|
||||
|
@@ -11,9 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Annotation;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
class RouteTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
|
@@ -11,13 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\CompiledRoute;
|
||||
|
||||
class CompiledRouteTest extends \PHPUnit_Framework_TestCase
|
||||
class CompiledRouteTest extends TestCase
|
||||
{
|
||||
public function testAccessors()
|
||||
{
|
||||
$compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), array(), array(), array(), array('variables'));
|
||||
$compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), null, array(), array(), array('variables'));
|
||||
$this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its second argument');
|
||||
$this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its third argument');
|
||||
$this->assertEquals(array('tokens'), $compiled->getTokens(), '__construct() takes an array of tokens as its fourth argument');
|
||||
|
36
vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php
vendored
Normal file
36
vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
|
||||
|
||||
class RoutingResolverPassTest extends TestCase
|
||||
{
|
||||
public function testProcess()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('routing.resolver', LoaderResolver::class);
|
||||
$container->register('loader1')->addTag('routing.loader');
|
||||
$container->register('loader2')->addTag('routing.loader');
|
||||
|
||||
(new RoutingResolverPass())->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(array('addLoader', array(new Reference('loader1'))), array('addLoader', array(new Reference('loader2')))),
|
||||
$container->getDefinition('routing.resolver')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
}
|
19
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php
vendored
Normal file
19
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||
|
||||
class BazClass
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
}
|
||||
}
|
18
vendor/symfony/routing/Tests/Fixtures/CustomCompiledRoute.php
vendored
Normal file
18
vendor/symfony/routing/Tests/Fixtures/CustomCompiledRoute.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\CompiledRoute;
|
||||
|
||||
class CustomCompiledRoute extends CompiledRoute
|
||||
{
|
||||
}
|
26
vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php
vendored
Normal file
26
vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
class CustomRouteCompiler extends RouteCompiler
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function compile(Route $route)
|
||||
{
|
||||
return new CustomCompiledRoute('', '', array(), array());
|
||||
}
|
||||
}
|
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
|
||||
/**
|
||||
* XmlFileLoader with schema validation turned off.
|
||||
|
24
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php
vendored
Normal file
24
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\OtherAnnotatedClasses;
|
||||
|
||||
trait AnonymousClassInTrait
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
return new class() {
|
||||
public function foo()
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
3
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class NoStartTagClass
|
||||
{
|
||||
}
|
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
|
10
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml">
|
||||
<default key="_controller">FrameworkBundle:Template:template</default>
|
||||
</import>
|
||||
</routes>
|
4
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml
vendored
Normal file
4
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
_static:
|
||||
resource: routing.yml
|
||||
defaults:
|
||||
_controller: FrameworkBundle:Template:template
|
8
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml" controller="FrameworkBundle:Template:template" />
|
||||
</routes>
|
3
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
_static:
|
||||
resource: routing.yml
|
||||
controller: FrameworkBundle:Template:template
|
10
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml" controller="FrameworkBundle:Template:template">
|
||||
<default key="_controller">AppBundle:Blog:index</default>
|
||||
</import>
|
||||
</routes>
|
5
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml
vendored
Normal file
5
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
_static:
|
||||
resource: routing.yml
|
||||
controller: FrameworkBundle:Template:template
|
||||
defaults:
|
||||
_controller: AppBundle:Homepage:show
|
10
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="app_blog" path="/blog" controller="AppBundle:Homepage:show">
|
||||
<default key="_controller">AppBundle:Blog:index</default>
|
||||
</route>
|
||||
</routes>
|
5
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml
vendored
Normal file
5
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
app_blog:
|
||||
path: /blog
|
||||
controller: AppBundle:Homepage:show
|
||||
defaults:
|
||||
_controller: AppBundle:Blog:index
|
14
vendor/symfony/routing/Tests/Fixtures/controller/routing.xml
vendored
Normal file
14
vendor/symfony/routing/Tests/Fixtures/controller/routing.xml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="app_homepage" path="/" controller="AppBundle:Homepage:show" />
|
||||
|
||||
<route id="app_blog" path="/blog">
|
||||
<default key="_controller">AppBundle:Blog:list</default>
|
||||
</route>
|
||||
|
||||
<route id="app_logout" path="/logout" />
|
||||
</routes>
|
11
vendor/symfony/routing/Tests/Fixtures/controller/routing.yml
vendored
Normal file
11
vendor/symfony/routing/Tests/Fixtures/controller/routing.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
app_homepage:
|
||||
path: /
|
||||
controller: AppBundle:Homepage:show
|
||||
|
||||
app_blog:
|
||||
path: /blog
|
||||
defaults:
|
||||
_controller: AppBundle:Blog:list
|
||||
|
||||
app_logout:
|
||||
path: /logout
|
37
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php
vendored
Normal file
37
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
@@ -1,163 +0,0 @@
|
||||
# skip "real" requests
|
||||
RewriteCond %{REQUEST_FILENAME} -f
|
||||
RewriteRule .* - [QSA,L]
|
||||
|
||||
# foo
|
||||
RewriteCond %{REQUEST_URI} ^/foo/(baz|symfony)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:foo,E=_ROUTING_param_bar:%1,E=_ROUTING_default_def:test]
|
||||
|
||||
# foobar
|
||||
RewriteCond %{REQUEST_URI} ^/foo(?:/([^/]++))?$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:foobar,E=_ROUTING_param_bar:%1,E=_ROUTING_default_bar:toto]
|
||||
|
||||
# bar
|
||||
RewriteCond %{REQUEST_URI} ^/bar/([^/]++)$
|
||||
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [NC]
|
||||
RewriteRule .* - [S=1,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_HEAD:1]
|
||||
RewriteCond %{REQUEST_URI} ^/bar/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:bar,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baragain
|
||||
RewriteCond %{REQUEST_URI} ^/baragain/([^/]++)$
|
||||
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$ [NC]
|
||||
RewriteRule .* - [S=1,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_POST:1,E=_ROUTING_allow_HEAD:1]
|
||||
RewriteCond %{REQUEST_URI} ^/baragain/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baragain,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz]
|
||||
|
||||
# baz2
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz\.html$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz2]
|
||||
|
||||
# baz3
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz3$
|
||||
RewriteRule .* $0/ [QSA,L,R=301]
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz3/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz3]
|
||||
|
||||
# baz4
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)$
|
||||
RewriteRule .* $0/ [QSA,L,R=301]
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz4,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz5
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$
|
||||
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [NC]
|
||||
RewriteRule .* - [S=2,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_HEAD:1]
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)$
|
||||
RewriteRule .* $0/ [QSA,L,R=301]
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz5,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz5unsafe
|
||||
RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]++)/$
|
||||
RewriteCond %{REQUEST_METHOD} !^(POST)$ [NC]
|
||||
RewriteRule .* - [S=1,E=_ROUTING_allow_POST:1]
|
||||
RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]++)/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz5unsafe,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz6
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz6,E=_ROUTING_default_foo:bar\ baz]
|
||||
|
||||
# baz7
|
||||
RewriteCond %{REQUEST_URI} ^/te\ st/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz7]
|
||||
|
||||
# baz8
|
||||
RewriteCond %{REQUEST_URI} ^/te\\\ st/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz8]
|
||||
|
||||
# baz9
|
||||
RewriteCond %{REQUEST_URI} ^/test/(te\\\ st)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz9,E=_ROUTING_param_baz:%1]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^a\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_1:1]
|
||||
|
||||
# route1
|
||||
RewriteCond %{ENV:__ROUTING_host_1} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route1$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route1]
|
||||
|
||||
# route2
|
||||
RewriteCond %{ENV:__ROUTING_host_1} =1
|
||||
RewriteCond %{REQUEST_URI} ^/c2/route2$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route2]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^b\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_2:1]
|
||||
|
||||
# route3
|
||||
RewriteCond %{ENV:__ROUTING_host_2} =1
|
||||
RewriteCond %{REQUEST_URI} ^/c2/route3$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route3]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^a\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_3:1]
|
||||
|
||||
# route4
|
||||
RewriteCond %{ENV:__ROUTING_host_3} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route4$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route4]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^c\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_4:1]
|
||||
|
||||
# route5
|
||||
RewriteCond %{ENV:__ROUTING_host_4} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route5$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route5]
|
||||
|
||||
# route6
|
||||
RewriteCond %{REQUEST_URI} ^/route6$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route6]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^([^\.]++)\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_5:1,E=__ROUTING_host_5_var1:%1]
|
||||
|
||||
# route11
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route11$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route11,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1}]
|
||||
|
||||
# route12
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route12$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route12,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_default_var1:val]
|
||||
|
||||
# route13
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route13/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route13,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1]
|
||||
|
||||
# route14
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route14/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route14,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^c\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_6:1]
|
||||
|
||||
# route15
|
||||
RewriteCond %{ENV:__ROUTING_host_6} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route15/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route15,E=_ROUTING_param_name:%1]
|
||||
|
||||
# route16
|
||||
RewriteCond %{REQUEST_URI} ^/route16/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route16,E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val]
|
||||
|
||||
# route17
|
||||
RewriteCond %{REQUEST_URI} ^/route17$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route17]
|
||||
|
||||
# 405 Method Not Allowed
|
||||
RewriteCond %{ENV:_ROUTING__allow_GET} =1 [OR]
|
||||
RewriteCond %{ENV:_ROUTING__allow_HEAD} =1 [OR]
|
||||
RewriteCond %{ENV:_ROUTING__allow_POST} =1
|
||||
RewriteRule .* app.php [QSA,L]
|
@@ -5,148 +5,156 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// foo
|
||||
if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/bar')) {
|
||||
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',));
|
||||
}
|
||||
|
||||
// foofoo
|
||||
if ('/foofoo' === $pathinfo) {
|
||||
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/bar')) {
|
||||
// bar
|
||||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bar:
|
||||
|
||||
// barhead
|
||||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('GET', 'HEAD'));
|
||||
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 $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_barhead:
|
||||
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/test')) {
|
||||
elseif (0 === strpos($pathinfo, '/test')) {
|
||||
if (0 === strpos($pathinfo, '/test/baz')) {
|
||||
// baz
|
||||
if ($pathinfo === '/test/baz') {
|
||||
if ('/test/baz' === $pathinfo) {
|
||||
return array('_route' => 'baz');
|
||||
}
|
||||
|
||||
// baz2
|
||||
if ($pathinfo === '/test/baz.html') {
|
||||
if ('/test/baz.html' === $pathinfo) {
|
||||
return array('_route' => 'baz2');
|
||||
}
|
||||
|
||||
// baz3
|
||||
if ($pathinfo === '/test/baz3/') {
|
||||
if ('/test/baz3/' === $pathinfo) {
|
||||
return array('_route' => 'baz3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// baz4
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
|
||||
}
|
||||
|
||||
// baz5
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ($this->context->getMethod() != 'POST') {
|
||||
$allow[] = 'POST';
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ($this->context->getMethod() != 'PUT') {
|
||||
$allow[] = 'PUT';
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bazbaz6:
|
||||
|
||||
}
|
||||
|
||||
// foofoo
|
||||
if ($pathinfo === '/foofoo') {
|
||||
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
||||
}
|
||||
|
||||
// quoter
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
|
||||
}
|
||||
|
||||
// space
|
||||
if ($pathinfo === '/spa ce') {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>.*)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
|
||||
}
|
||||
|
||||
@@ -154,110 +162,110 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/multi')) {
|
||||
elseif (0 === strpos($pathinfo, '/multi')) {
|
||||
// helloWorld
|
||||
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
|
||||
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!',));
|
||||
}
|
||||
|
||||
// overridden2
|
||||
if ($pathinfo === '/multi/new') {
|
||||
return array('_route' => 'overridden2');
|
||||
// hey
|
||||
if ('/multi/hey/' === $pathinfo) {
|
||||
return array('_route' => 'hey');
|
||||
}
|
||||
|
||||
// hey
|
||||
if ($pathinfo === '/multi/hey/') {
|
||||
return array('_route' => 'hey');
|
||||
// overridden2
|
||||
if ('/multi/new' === $pathinfo) {
|
||||
return array('_route' => 'overridden2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// foo3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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 ($pathinfo === '/ababa') {
|
||||
if ('/ababa' === $pathinfo) {
|
||||
return array('_route' => 'ababa');
|
||||
}
|
||||
|
||||
// foo4
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$host = $this->context->getHost();
|
||||
$host = $context->getHost();
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route1
|
||||
if ($pathinfo === '/route1') {
|
||||
if ('/route1' === $pathinfo) {
|
||||
return array('_route' => 'route1');
|
||||
}
|
||||
|
||||
// route2
|
||||
if ($pathinfo === '/c2/route2') {
|
||||
if ('/c2/route2' === $pathinfo) {
|
||||
return array('_route' => 'route2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route3
|
||||
if ($pathinfo === '/c2/route3') {
|
||||
if ('/c2/route3' === $pathinfo) {
|
||||
return array('_route' => 'route3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route4
|
||||
if ($pathinfo === '/route4') {
|
||||
if ('/route4' === $pathinfo) {
|
||||
return array('_route' => 'route4');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route5
|
||||
if ($pathinfo === '/route5') {
|
||||
if ('/route5' === $pathinfo) {
|
||||
return array('_route' => 'route5');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route6
|
||||
if ($pathinfo === '/route6') {
|
||||
if ('/route6' === $pathinfo) {
|
||||
return array('_route' => 'route6');
|
||||
}
|
||||
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route11
|
||||
if ($pathinfo === '/route11') {
|
||||
if ('/route11' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
|
||||
}
|
||||
|
||||
// route12
|
||||
if ($pathinfo === '/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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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',));
|
||||
}
|
||||
|
||||
@@ -265,46 +273,44 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route15
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route16
|
||||
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
|
||||
// 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 ());
|
||||
}
|
||||
|
||||
// route17
|
||||
if ($pathinfo === '/route17') {
|
||||
return array('_route' => 'route17');
|
||||
// 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 ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
// a
|
||||
if ($pathinfo === '/a/a...') {
|
||||
return array('_route' => 'a');
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b')) {
|
||||
// b
|
||||
if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
|
@@ -1,7 +0,0 @@
|
||||
# skip "real" requests
|
||||
RewriteCond %{REQUEST_FILENAME} -f
|
||||
RewriteRule .* - [QSA,L]
|
||||
|
||||
# foo
|
||||
RewriteCond %{REQUEST_URI} ^/foo$
|
||||
RewriteRule .* ap\ p_d\ ev.php [QSA,L,E=_ROUTING_route:foo]
|
@@ -5,156 +5,176 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// foo
|
||||
if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/bar')) {
|
||||
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',));
|
||||
}
|
||||
|
||||
// foofoo
|
||||
if ('/foofoo' === $pathinfo) {
|
||||
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/bar')) {
|
||||
// bar
|
||||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bar:
|
||||
|
||||
// barhead
|
||||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('GET', 'HEAD'));
|
||||
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 $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_barhead:
|
||||
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/test')) {
|
||||
elseif (0 === strpos($pathinfo, '/test')) {
|
||||
if (0 === strpos($pathinfo, '/test/baz')) {
|
||||
// baz
|
||||
if ($pathinfo === '/test/baz') {
|
||||
if ('/test/baz' === $pathinfo) {
|
||||
return array('_route' => 'baz');
|
||||
}
|
||||
|
||||
// baz2
|
||||
if ($pathinfo === '/test/baz.html') {
|
||||
if ('/test/baz.html' === $pathinfo) {
|
||||
return array('_route' => 'baz2');
|
||||
}
|
||||
|
||||
// baz3
|
||||
if (rtrim($pathinfo, '/') === '/test/baz3') {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', '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'));
|
||||
}
|
||||
|
||||
return array('_route' => 'baz3');
|
||||
return $ret;
|
||||
}
|
||||
not_baz3:
|
||||
|
||||
}
|
||||
|
||||
// baz4
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/?$#s', $pathinfo, $matches)) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', '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'));
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_baz4:
|
||||
|
||||
// baz5
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ($this->context->getMethod() != 'POST') {
|
||||
$allow[] = 'POST';
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ($this->context->getMethod() != 'PUT') {
|
||||
$allow[] = 'PUT';
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bazbaz6:
|
||||
|
||||
}
|
||||
|
||||
// foofoo
|
||||
if ($pathinfo === '/foofoo') {
|
||||
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
||||
}
|
||||
|
||||
// quoter
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
|
||||
}
|
||||
|
||||
// space
|
||||
if ($pathinfo === '/spa ce') {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>.*)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
|
||||
}
|
||||
|
||||
@@ -162,114 +182,120 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/multi')) {
|
||||
elseif (0 === strpos($pathinfo, '/multi')) {
|
||||
// helloWorld
|
||||
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
|
||||
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!',));
|
||||
}
|
||||
|
||||
// overridden2
|
||||
if ($pathinfo === '/multi/new') {
|
||||
return array('_route' => 'overridden2');
|
||||
}
|
||||
|
||||
// hey
|
||||
if (rtrim($pathinfo, '/') === '/multi/hey') {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', '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 array('_route' => 'hey');
|
||||
return $ret;
|
||||
}
|
||||
not_hey:
|
||||
|
||||
// overridden2
|
||||
if ('/multi/new' === $pathinfo) {
|
||||
return array('_route' => 'overridden2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// foo3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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 ($pathinfo === '/ababa') {
|
||||
if ('/ababa' === $pathinfo) {
|
||||
return array('_route' => 'ababa');
|
||||
}
|
||||
|
||||
// foo4
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$host = $this->context->getHost();
|
||||
$host = $context->getHost();
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route1
|
||||
if ($pathinfo === '/route1') {
|
||||
if ('/route1' === $pathinfo) {
|
||||
return array('_route' => 'route1');
|
||||
}
|
||||
|
||||
// route2
|
||||
if ($pathinfo === '/c2/route2') {
|
||||
if ('/c2/route2' === $pathinfo) {
|
||||
return array('_route' => 'route2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route3
|
||||
if ($pathinfo === '/c2/route3') {
|
||||
if ('/c2/route3' === $pathinfo) {
|
||||
return array('_route' => 'route3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route4
|
||||
if ($pathinfo === '/route4') {
|
||||
if ('/route4' === $pathinfo) {
|
||||
return array('_route' => 'route4');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route5
|
||||
if ($pathinfo === '/route5') {
|
||||
if ('/route5' === $pathinfo) {
|
||||
return array('_route' => 'route5');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route6
|
||||
if ($pathinfo === '/route6') {
|
||||
if ('/route6' === $pathinfo) {
|
||||
return array('_route' => 'route6');
|
||||
}
|
||||
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route11
|
||||
if ($pathinfo === '/route11') {
|
||||
if ('/route11' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
|
||||
}
|
||||
|
||||
// route12
|
||||
if ($pathinfo === '/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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
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',));
|
||||
}
|
||||
|
||||
@@ -277,66 +303,76 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route15
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route16
|
||||
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
// route17
|
||||
if ($pathinfo === '/route17') {
|
||||
return array('_route' => 'route17');
|
||||
}
|
||||
|
||||
// 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',));
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
// a
|
||||
if ($pathinfo === '/a/a...') {
|
||||
return array('_route' => 'a');
|
||||
// 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 ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b')) {
|
||||
// b
|
||||
if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $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>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), 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 ($pathinfo === '/secure') {
|
||||
if ('/secure' === $pathinfo) {
|
||||
$ret = array('_route' => 'secure');
|
||||
$requiredSchemes = array ( 'https' => 0,);
|
||||
if (!isset($requiredSchemes[$this->context->getScheme()])) {
|
||||
return $this->redirect($pathinfo, 'secure', key($requiredSchemes));
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_secure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'secure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
return array('_route' => 'secure');
|
||||
return $ret;
|
||||
}
|
||||
not_secure:
|
||||
|
||||
// nonsecure
|
||||
if ($pathinfo === '/nonsecure') {
|
||||
if ('/nonsecure' === $pathinfo) {
|
||||
$ret = array('_route' => 'nonsecure');
|
||||
$requiredSchemes = array ( 'http' => 0,);
|
||||
if (!isset($requiredSchemes[$this->context->getScheme()])) {
|
||||
return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes));
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_nonsecure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
return array('_route' => 'nonsecure');
|
||||
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();
|
||||
|
@@ -5,46 +5,51 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/rootprefix')) {
|
||||
// static
|
||||
if ($pathinfo === '/rootprefix/test') {
|
||||
if ('/rootprefix/test' === $pathinfo) {
|
||||
return array('_route' => 'static');
|
||||
}
|
||||
|
||||
// dynamic
|
||||
if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// with-condition
|
||||
if ($pathinfo === '/with-condition' && ($context->getMethod() == "GET")) {
|
||||
if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) {
|
||||
return array('_route' => 'with-condition');
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
||||
|
112
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php
vendored
Normal file
112
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
// just_head
|
||||
if ('/just_head' === $pathinfo) {
|
||||
$ret = array('_route' => 'just_head');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_just_head;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_just_head:
|
||||
|
||||
// head_and_get
|
||||
if ('/head_and_get' === $pathinfo) {
|
||||
$ret = array('_route' => 'head_and_get');
|
||||
if (!in_array($canonicalMethod, array('HEAD', 'GET'))) {
|
||||
$allow = array_merge($allow, array('HEAD', 'GET'));
|
||||
goto not_head_and_get;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_head_and_get:
|
||||
|
||||
// get_and_head
|
||||
if ('/get_and_head' === $pathinfo) {
|
||||
$ret = array('_route' => 'get_and_head');
|
||||
if (!in_array($canonicalMethod, array('GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('GET', 'HEAD'));
|
||||
goto not_get_and_head;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_get_and_head:
|
||||
|
||||
// post_and_head
|
||||
if ('/post_and_head' === $pathinfo) {
|
||||
$ret = array('_route' => 'post_and_head');
|
||||
if (!in_array($requestMethod, array('POST', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('POST', 'HEAD'));
|
||||
goto not_post_and_head;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_post_and_head:
|
||||
|
||||
if (0 === strpos($pathinfo, '/put_and_post')) {
|
||||
// put_and_post
|
||||
if ('/put_and_post' === $pathinfo) {
|
||||
$ret = array('_route' => 'put_and_post');
|
||||
if (!in_array($requestMethod, array('PUT', 'POST'))) {
|
||||
$allow = array_merge($allow, array('PUT', 'POST'));
|
||||
goto not_put_and_post;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_put_and_post:
|
||||
|
||||
// put_and_get_and_head
|
||||
if ('/put_and_post' === $pathinfo) {
|
||||
$ret = array('_route' => 'put_and_get_and_head');
|
||||
if (!in_array($canonicalMethod, array('PUT', 'GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('PUT', 'GET', 'HEAD'));
|
||||
goto not_put_and_get_and_head;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_put_and_get_and_head:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
209
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php
vendored
Normal file
209
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
// a_first
|
||||
if ('/a/11' === $pathinfo) {
|
||||
return array('_route' => 'a_first');
|
||||
}
|
||||
|
||||
// a_second
|
||||
if ('/a/22' === $pathinfo) {
|
||||
return array('_route' => 'a_second');
|
||||
}
|
||||
|
||||
// a_third
|
||||
if ('/a/333' === $pathinfo) {
|
||||
return array('_route' => 'a_third');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// a_wildcard
|
||||
if (preg_match('#^/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'a_wildcard')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
// a_fourth
|
||||
if ('/a/44' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'a_fourth');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_a_fourth;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fourth'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_a_fourth:
|
||||
|
||||
// a_fifth
|
||||
if ('/a/55' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'a_fifth');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_a_fifth;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fifth'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_a_fifth:
|
||||
|
||||
// a_sixth
|
||||
if ('/a/66' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'a_sixth');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_a_sixth;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_sixth'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_a_sixth:
|
||||
|
||||
}
|
||||
|
||||
// nested_wildcard
|
||||
if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'nested_wildcard')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/nested/group')) {
|
||||
// nested_a
|
||||
if ('/nested/group/a' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'nested_a');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_nested_a;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_a'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_nested_a:
|
||||
|
||||
// nested_b
|
||||
if ('/nested/group/b' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'nested_b');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_nested_b;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_b'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_nested_b:
|
||||
|
||||
// nested_c
|
||||
if ('/nested/group/c' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'nested_c');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_nested_c;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_c'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_nested_c:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/slashed/group')) {
|
||||
// slashed_a
|
||||
if ('/slashed/group' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'slashed_a');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_slashed_a;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_a'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_slashed_a:
|
||||
|
||||
// slashed_b
|
||||
if ('/slashed/group/b' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'slashed_b');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_slashed_b;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_b'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_slashed_b:
|
||||
|
||||
// slashed_c
|
||||
if ('/slashed/group/c' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'slashed_c');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_slashed_c;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_c'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_slashed_c:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
213
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php
vendored
Normal file
213
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/trailing/simple')) {
|
||||
// simple_trailing_slash_no_methods
|
||||
if ('/trailing/simple/no-methods/' === $pathinfo) {
|
||||
return array('_route' => 'simple_trailing_slash_no_methods');
|
||||
}
|
||||
|
||||
// simple_trailing_slash_GET_method
|
||||
if ('/trailing/simple/get-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_GET_method');
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_GET_method:
|
||||
|
||||
// simple_trailing_slash_HEAD_method
|
||||
if ('/trailing/simple/head-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_trailing_slash_POST_method
|
||||
if ('/trailing/simple/post-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/trailing/regex')) {
|
||||
// regex_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
|
||||
}
|
||||
|
||||
// regex_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_GET_method:
|
||||
|
||||
// regex_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/simple')) {
|
||||
// simple_not_trailing_slash_no_methods
|
||||
if ('/not-trailing/simple/no-methods' === $pathinfo) {
|
||||
return array('_route' => 'simple_not_trailing_slash_no_methods');
|
||||
}
|
||||
|
||||
// simple_not_trailing_slash_GET_method
|
||||
if ('/not-trailing/simple/get-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_GET_method');
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_GET_method:
|
||||
|
||||
// simple_not_trailing_slash_HEAD_method
|
||||
if ('/not-trailing/simple/head-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_not_trailing_slash_POST_method
|
||||
if ('/not-trailing/simple/post-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/regex')) {
|
||||
// regex_not_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ());
|
||||
}
|
||||
|
||||
// regex_not_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_GET_method:
|
||||
|
||||
// regex_not_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_not_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
249
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php
vendored
Normal file
249
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/trailing/simple')) {
|
||||
// simple_trailing_slash_no_methods
|
||||
if ('/trailing/simple/no-methods' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_no_methods');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_simple_trailing_slash_no_methods;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_no_methods'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_no_methods:
|
||||
|
||||
// simple_trailing_slash_GET_method
|
||||
if ('/trailing/simple/get-method' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_GET_method');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_GET_method'));
|
||||
}
|
||||
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_GET_method:
|
||||
|
||||
// simple_trailing_slash_HEAD_method
|
||||
if ('/trailing/simple/head-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_trailing_slash_POST_method
|
||||
if ('/trailing/simple/post-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/trailing/regex')) {
|
||||
// regex_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_regex_trailing_slash_no_methods;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_no_methods'));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_no_methods:
|
||||
|
||||
// regex_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_GET_method'));
|
||||
}
|
||||
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_GET_method:
|
||||
|
||||
// regex_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/simple')) {
|
||||
// simple_not_trailing_slash_no_methods
|
||||
if ('/not-trailing/simple/no-methods' === $pathinfo) {
|
||||
return array('_route' => 'simple_not_trailing_slash_no_methods');
|
||||
}
|
||||
|
||||
// simple_not_trailing_slash_GET_method
|
||||
if ('/not-trailing/simple/get-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_GET_method');
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_GET_method:
|
||||
|
||||
// simple_not_trailing_slash_HEAD_method
|
||||
if ('/not-trailing/simple/head-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_not_trailing_slash_POST_method
|
||||
if ('/not-trailing/simple/post-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/regex')) {
|
||||
// regex_not_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ());
|
||||
}
|
||||
|
||||
// regex_not_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_GET_method:
|
||||
|
||||
// regex_not_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_not_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
8
vendor/symfony/routing/Tests/Fixtures/glob/bar.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/bar.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="bar_route" path="/bar" controller="AppBundle:Bar:view" />
|
||||
</routes>
|
4
vendor/symfony/routing/Tests/Fixtures/glob/bar.yml
vendored
Normal file
4
vendor/symfony/routing/Tests/Fixtures/glob/bar.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
bar_route:
|
||||
path: /bar
|
||||
defaults:
|
||||
_controller: AppBundle:Bar:view
|
8
vendor/symfony/routing/Tests/Fixtures/glob/baz.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/baz.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="baz_route" path="/baz" controller="AppBundle:Baz:view" />
|
||||
</routes>
|
4
vendor/symfony/routing/Tests/Fixtures/glob/baz.yml
vendored
Normal file
4
vendor/symfony/routing/Tests/Fixtures/glob/baz.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
baz_route:
|
||||
path: /baz
|
||||
defaults:
|
||||
_controller: AppBundle:Baz:view
|
8
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="ba?.xml" />
|
||||
</routes>
|
2
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
_static:
|
||||
resource: ba?.yml
|
8
vendor/symfony/routing/Tests/Fixtures/glob/import_single.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/import_single.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="b?r.xml" />
|
||||
</routes>
|
2
vendor/symfony/routing/Tests/Fixtures/glob/import_single.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/glob/import_single.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
_static:
|
||||
resource: b?r.yml
|
7
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl.php
vendored
Normal file
7
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
return $routes->import('php_dsl_ba?.php');
|
||||
};
|
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_bar.php
vendored
Normal file
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_bar.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$collection = $routes->collection();
|
||||
|
||||
$collection->add('bar_route', '/bar')
|
||||
->defaults(array('_controller' => 'AppBundle:Bar:view'));
|
||||
|
||||
return $collection;
|
||||
};
|
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_baz.php
vendored
Normal file
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_baz.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$collection = $routes->collection();
|
||||
|
||||
$collection->add('baz_route', '/baz')
|
||||
->defaults(array('_controller' => 'AppBundle:Baz:view'));
|
||||
|
||||
return $collection;
|
||||
};
|
20
vendor/symfony/routing/Tests/Fixtures/list_defaults.xml
vendored
Normal file
20
vendor/symfony/routing/Tests/Fixtures/list_defaults.xml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<list>
|
||||
<bool>true</bool>
|
||||
<int>1</int>
|
||||
<float>3.5</float>
|
||||
<string>foo</string>
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<list>
|
||||
<list>
|
||||
<bool>true</bool>
|
||||
<int>1</int>
|
||||
<float>3.5</float>
|
||||
<string>foo</string>
|
||||
</list>
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<map>
|
||||
<list key="list">
|
||||
<bool>true</bool>
|
||||
<int>1</int>
|
||||
<float>3.5</float>
|
||||
<string>foo</string>
|
||||
</list>
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/list_null_values.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/list_null_values.xml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="list">
|
||||
<list>
|
||||
<bool xsi:nil="true" />
|
||||
<int xsi:nil="true" />
|
||||
<float xsi:nil="1" />
|
||||
<string xsi:nil="true" />
|
||||
<list xsi:nil="true" />
|
||||
<map xsi:nil="true" />
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
20
vendor/symfony/routing/Tests/Fixtures/map_defaults.xml
vendored
Normal file
20
vendor/symfony/routing/Tests/Fixtures/map_defaults.xml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<map>
|
||||
<bool key="public">true</bool>
|
||||
<int key="page">1</int>
|
||||
<float key="price">3.5</float>
|
||||
<string key="title">foo</string>
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<list>
|
||||
<map>
|
||||
<bool key="public">true</bool>
|
||||
<int key="page">1</int>
|
||||
<float key="price">3.5</float>
|
||||
<string key="title">foo</string>
|
||||
</map>
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<map>
|
||||
<map key="map">
|
||||
<bool key="public">true</bool>
|
||||
<int key="page">1</int>
|
||||
<float key="price">3.5</float>
|
||||
<string key="title">foo</string>
|
||||
</map>
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/map_null_values.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/map_null_values.xml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="map">
|
||||
<map>
|
||||
<bool key="boolean" xsi:nil="true" />
|
||||
<int key="integer" xsi:nil="true" />
|
||||
<float key="float" xsi:nil="true" />
|
||||
<string key="string" xsi:nil="1" />
|
||||
<list key="list" xsi:nil="true" />
|
||||
<map key="map" xsi:nil="true" />
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
@@ -9,5 +9,8 @@
|
||||
<requirement xmlns="http://symfony.com/schema/routing" key="slug">\w+</requirement>
|
||||
<r2:requirement xmlns:r2="http://symfony.com/schema/routing" key="_locale">en|fr|de</r2:requirement>
|
||||
<r:option key="compiler_class">RouteCompiler</r:option>
|
||||
<r:default key="page">
|
||||
<r3:int xmlns:r3="http://symfony.com/schema/routing">1</r3:int>
|
||||
</r:default>
|
||||
</r:route>
|
||||
</r:routes>
|
||||
|
22
vendor/symfony/routing/Tests/Fixtures/php_dsl.php
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/php_dsl.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$routes
|
||||
->collection()
|
||||
->add('foo', '/foo')
|
||||
->condition('abc')
|
||||
->options(array('utf8' => true))
|
||||
->add('buz', 'zub')
|
||||
->controller('foo:act');
|
||||
|
||||
$routes->import('php_dsl_sub.php')
|
||||
->prefix('/sub')
|
||||
->requirements(array('id' => '\d+'));
|
||||
|
||||
$routes->add('ouf', '/ouf')
|
||||
->schemes(array('https'))
|
||||
->methods(array('GET'))
|
||||
->defaults(array('id' => 0));
|
||||
};
|
14
vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php
vendored
Normal file
14
vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$add = $routes->collection('c_')
|
||||
->prefix('pub');
|
||||
|
||||
$add('bar', '/bar');
|
||||
|
||||
$add->collection('pub_')
|
||||
->host('host')
|
||||
->add('buz', 'buz');
|
||||
};
|
33
vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml
vendored
Normal file
33
vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="slug" xsi:nil="true" />
|
||||
<default key="published">
|
||||
<bool>true</bool>
|
||||
</default>
|
||||
<default key="page">
|
||||
<int>1</int>
|
||||
</default>
|
||||
<default key="price">
|
||||
<float>3.5</float>
|
||||
</default>
|
||||
<default key="archived">
|
||||
<bool>false</bool>
|
||||
</default>
|
||||
<default key="free">
|
||||
<bool>1</bool>
|
||||
</default>
|
||||
<default key="locked">
|
||||
<bool>0</bool>
|
||||
</default>
|
||||
<default key="foo" xsi:nil="true" />
|
||||
<default key="bar" xsi:nil="1" />
|
||||
</route>
|
||||
</routes>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user