updated packages
This commit is contained in:
16
vendor/symfony/routing/Annotation/Route.php
vendored
16
vendor/symfony/routing/Annotation/Route.php
vendored
@@ -22,14 +22,14 @@ namespace Symfony\Component\Routing\Annotation;
|
||||
class Route
|
||||
{
|
||||
private $path;
|
||||
private $localizedPaths = array();
|
||||
private $localizedPaths = [];
|
||||
private $name;
|
||||
private $requirements = array();
|
||||
private $options = array();
|
||||
private $defaults = array();
|
||||
private $requirements = [];
|
||||
private $options = [];
|
||||
private $defaults = [];
|
||||
private $host;
|
||||
private $methods = array();
|
||||
private $schemes = array();
|
||||
private $methods = [];
|
||||
private $schemes = [];
|
||||
private $condition;
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ class Route
|
||||
|
||||
public function setSchemes($schemes)
|
||||
{
|
||||
$this->schemes = \is_array($schemes) ? $schemes : array($schemes);
|
||||
$this->schemes = \is_array($schemes) ? $schemes : [$schemes];
|
||||
}
|
||||
|
||||
public function getSchemes()
|
||||
@@ -144,7 +144,7 @@ class Route
|
||||
|
||||
public function setMethods($methods)
|
||||
{
|
||||
$this->methods = \is_array($methods) ? $methods : array($methods);
|
||||
$this->methods = \is_array($methods) ? $methods : [$methods];
|
||||
}
|
||||
|
||||
public function getMethods()
|
||||
|
||||
14
vendor/symfony/routing/CHANGELOG.md
vendored
14
vendor/symfony/routing/CHANGELOG.md
vendored
@@ -52,7 +52,7 @@ CHANGELOG
|
||||
Before:
|
||||
|
||||
```php
|
||||
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
|
||||
$router->generate('blog_show', ['slug' => 'my-blog-post'], true);
|
||||
```
|
||||
|
||||
After:
|
||||
@@ -60,7 +60,7 @@ CHANGELOG
|
||||
```php
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
$router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$router->generate('blog_show', ['slug' => 'my-blog-post'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
```
|
||||
|
||||
2.5.0
|
||||
@@ -68,7 +68,7 @@ CHANGELOG
|
||||
|
||||
* [DEPRECATION] The `ApacheMatcherDumper` and `ApacheUrlMatcher` were deprecated and
|
||||
will be removed in Symfony 3.0, since the performance gains were minimal and
|
||||
it's hard to replicate the behaviour of PHP implementation.
|
||||
it's hard to replicate the behavior of PHP implementation.
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
@@ -125,7 +125,7 @@ CHANGELOG
|
||||
```php
|
||||
$route = new Route();
|
||||
$route->setPath('/article/{id}');
|
||||
$route->setMethods(array('POST', 'PUT'));
|
||||
$route->setMethods(['POST', 'PUT']);
|
||||
$route->setSchemes('https');
|
||||
```
|
||||
|
||||
@@ -180,10 +180,10 @@ CHANGELOG
|
||||
used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
|
||||
will still work, but have been deprecated. The `addPrefix` method should be used for this
|
||||
use-case instead.
|
||||
Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
|
||||
Before: `$parentCollection->addCollection($collection, '/prefix', [...], [...])`
|
||||
After:
|
||||
```php
|
||||
$collection->addPrefix('/prefix', array(...), array(...));
|
||||
$collection->addPrefix('/prefix', [...], [...]);
|
||||
$parentCollection->addCollection($collection);
|
||||
```
|
||||
* added support for the method default argument values when defining a @Route
|
||||
@@ -208,7 +208,7 @@ CHANGELOG
|
||||
(only relevant if you implemented your own RouteCompiler).
|
||||
* Added possibility to generate relative paths and network paths in the UrlGenerator, e.g.
|
||||
"../parent-file" and "//example.com/dir/file". The third parameter in
|
||||
`UrlGeneratorInterface::generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)`
|
||||
`UrlGeneratorInterface::generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)`
|
||||
now accepts more values and you should use the constants defined in `UrlGeneratorInterface` for
|
||||
claritiy. The old method calls with a Boolean parameter will continue to work because they
|
||||
equal the signature using the constants.
|
||||
|
||||
8
vendor/symfony/routing/CompiledRoute.php
vendored
8
vendor/symfony/routing/CompiledRoute.php
vendored
@@ -37,7 +37,7 @@ class CompiledRoute implements \Serializable
|
||||
* @param array $hostVariables An array of host variables
|
||||
* @param array $variables An array of variables (variables defined in the path and in the host patterns)
|
||||
*/
|
||||
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
|
||||
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
|
||||
{
|
||||
$this->staticPrefix = $staticPrefix;
|
||||
$this->regex = $regex;
|
||||
@@ -54,7 +54,7 @@ class CompiledRoute implements \Serializable
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return serialize(array(
|
||||
return serialize([
|
||||
'vars' => $this->variables,
|
||||
'path_prefix' => $this->staticPrefix,
|
||||
'path_regex' => $this->regex,
|
||||
@@ -63,7 +63,7 @@ class CompiledRoute implements \Serializable
|
||||
'host_regex' => $this->hostRegex,
|
||||
'host_tokens' => $this->hostTokens,
|
||||
'host_vars' => $this->hostVariables,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ class CompiledRoute implements \Serializable
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$data = unserialize($serialized, array('allowed_classes' => false));
|
||||
$data = unserialize($serialized, ['allowed_classes' => false]);
|
||||
|
||||
$this->variables = $data['vars'];
|
||||
$this->staticPrefix = $data['path_prefix'];
|
||||
|
||||
@@ -43,7 +43,7 @@ class RoutingResolverPass implements CompilerPassInterface
|
||||
$definition = $container->getDefinition($this->resolverServiceId);
|
||||
|
||||
foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) {
|
||||
$definition->addMethodCall('addLoader', array(new Reference($id)));
|
||||
$definition->addMethodCall('addLoader', [new Reference($id)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Symfony\Component\Routing\Exception;
|
||||
*/
|
||||
class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
protected $allowedMethods = array();
|
||||
protected $allowedMethods = [];
|
||||
|
||||
public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Exception $previous = null)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ interface GeneratorDumperInterface
|
||||
*
|
||||
* @return string Executable code
|
||||
*/
|
||||
public function dump(array $options = array());
|
||||
public function dump(array $options = []);
|
||||
|
||||
/**
|
||||
* Gets the routes to dump.
|
||||
|
||||
@@ -33,12 +33,12 @@ class PhpGeneratorDumper extends GeneratorDumper
|
||||
*
|
||||
* @return string A PHP class representing the generator class
|
||||
*/
|
||||
public function dump(array $options = array())
|
||||
public function dump(array $options = [])
|
||||
{
|
||||
$options = array_merge(array(
|
||||
$options = array_merge([
|
||||
'class' => 'ProjectUrlGenerator',
|
||||
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
|
||||
), $options);
|
||||
], $options);
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
@@ -80,11 +80,11 @@ EOF;
|
||||
*/
|
||||
private function generateDeclaredRoutes()
|
||||
{
|
||||
$routes = "array(\n";
|
||||
$routes = "[\n";
|
||||
foreach ($this->getRoutes()->all() as $name => $route) {
|
||||
$compiledRoute = $route->compile();
|
||||
|
||||
$properties = array();
|
||||
$properties = [];
|
||||
$properties[] = $compiledRoute->getVariables();
|
||||
$properties[] = $route->getDefaults();
|
||||
$properties[] = $route->getRequirements();
|
||||
@@ -94,7 +94,7 @@ EOF;
|
||||
|
||||
$routes .= sprintf(" '%s' => %s,\n", $name, PhpMatcherDumper::export($properties));
|
||||
}
|
||||
$routes .= ' )';
|
||||
$routes .= ' ]';
|
||||
|
||||
return $routes;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ EOF;
|
||||
private function generateGenerateMethod()
|
||||
{
|
||||
return <<<'EOF'
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
$locale = $parameters['_locale']
|
||||
?? $this->context->getParameter('_locale')
|
||||
|
||||
@@ -47,7 +47,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
* "?" and "#" (would be interpreted wrongly as query and fragment identifier),
|
||||
* "'" and """ (are used as delimiters in HTML).
|
||||
*/
|
||||
protected $decodedChars = array(
|
||||
protected $decodedChars = [
|
||||
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
|
||||
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
|
||||
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
|
||||
@@ -65,7 +65,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
'%21' => '!',
|
||||
'%2A' => '*',
|
||||
'%7C' => '|',
|
||||
);
|
||||
];
|
||||
|
||||
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
$route = null;
|
||||
$locale = $parameters['_locale']
|
||||
@@ -141,7 +141,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
|
||||
* it does not match the requirement
|
||||
*/
|
||||
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
|
||||
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
|
||||
{
|
||||
$variables = array_flip($variables);
|
||||
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
|
||||
@@ -156,15 +156,15 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
$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].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
|
||||
if (!$optional || !\array_key_exists($token[3], $defaults) || null !== $mergedParams[$token[3]] && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) {
|
||||
// check requirement (while ignoring look-around patterns)
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.preg_replace('/\(\?(?:=|<=|!|<!)((?:[^()\\\\]+|\\\\.|\((?1)\))*)\)/', '', $token[2]).'$#'.(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]])));
|
||||
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
|
||||
}
|
||||
|
||||
if ($this->logger) {
|
||||
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
|
||||
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -190,7 +190,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
|
||||
// so we need to encode them as they are not used for this purpose here
|
||||
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
|
||||
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
|
||||
$url = strtr($url, ['/../' => '/%2E%2E/', '/./' => '/%2E/']);
|
||||
if ('/..' === substr($url, -3)) {
|
||||
$url = substr($url, 0, -2).'%2E%2E';
|
||||
} elseif ('/.' === substr($url, -2)) {
|
||||
@@ -212,13 +212,14 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
$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]])) {
|
||||
// check requirement (while ignoring look-around patterns)
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.preg_replace('/\(\?(?:=|<=|!|<!)((?:[^()\\\\]+|\\\\.|\((?1)\))*)\)/', '', $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]])));
|
||||
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
|
||||
}
|
||||
|
||||
if ($this->logger) {
|
||||
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
|
||||
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -272,11 +273,11 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
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' => '/'));
|
||||
$url .= '?'.strtr($query, ['%2F' => '/']);
|
||||
}
|
||||
|
||||
if ('' !== $fragment) {
|
||||
$url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?'));
|
||||
$url .= '#'.strtr(rawurlencode($fragment), ['%2F' => '/', '%3F' => '?']);
|
||||
}
|
||||
|
||||
return $url;
|
||||
|
||||
@@ -82,5 +82,5 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
|
||||
* it does not match the requirement
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH);
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
|
||||
$path = $annot->getLocalizedPaths() ?: $annot->getPath();
|
||||
$prefix = $globals['localized_paths'] ?: $globals['path'];
|
||||
$paths = array();
|
||||
$paths = [];
|
||||
|
||||
if (\is_array($path)) {
|
||||
if (!\is_array($prefix)) {
|
||||
@@ -196,7 +196,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
continue;
|
||||
}
|
||||
foreach ($paths as $locale => $path) {
|
||||
if (false !== strpos($path, sprintf('{%s}', $param->name))) {
|
||||
if (preg_match(sprintf('/\{%s(?:<.*?>)?\}/', preg_quote($param->name)), $path)) {
|
||||
$defaults[$param->name] = $param->getDefaultValue();
|
||||
break;
|
||||
}
|
||||
@@ -312,18 +312,18 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
|
||||
private function resetGlobals()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'path' => null,
|
||||
'localized_paths' => array(),
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
'schemes' => array(),
|
||||
'methods' => array(),
|
||||
'localized_paths' => [],
|
||||
'requirements' => [],
|
||||
'options' => [],
|
||||
'defaults' => [],
|
||||
'schemes' => [],
|
||||
'methods' => [],
|
||||
'host' => '',
|
||||
'condition' => '',
|
||||
'name' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition)
|
||||
|
||||
@@ -56,6 +56,11 @@ class AnnotationFileLoader extends FileLoader
|
||||
|
||||
$collection = new RouteCollection();
|
||||
if ($class = $this->findClass($path)) {
|
||||
$refl = new \ReflectionClass($class);
|
||||
if ($refl->isAbstract()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$collection->addResource(new FileResource($path));
|
||||
$collection->addCollection($this->loader->load($class, $type));
|
||||
}
|
||||
@@ -104,7 +109,7 @@ 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], [T_NS_SEPARATOR, T_STRING])) {
|
||||
$namespace .= $tokens[$i][1];
|
||||
}
|
||||
$token = $tokens[$i];
|
||||
@@ -121,7 +126,7 @@ class AnnotationFileLoader extends FileLoader
|
||||
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], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ trait AddTrait
|
||||
*/
|
||||
final public function add(string $name, $path): RouteConfigurator
|
||||
{
|
||||
$paths = array();
|
||||
$paths = [];
|
||||
$parentConfigurator = $this instanceof CollectionConfigurator ? $this : ($this instanceof RouteConfigurator ? $this->parentConfigurator : null);
|
||||
|
||||
if (\is_array($path)) {
|
||||
|
||||
@@ -120,7 +120,7 @@ trait RouteTrait
|
||||
*/
|
||||
final public function controller($controller)
|
||||
{
|
||||
$this->route->addDefaults(array('_controller' => $controller));
|
||||
$this->route->addDefaults(['_controller' => $controller]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ use Symfony\Component\Routing\Loader\ObjectRouteLoader;
|
||||
/**
|
||||
* A route loader that executes a service to load the routes.
|
||||
*
|
||||
* This depends on the DependencyInjection component.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@knpuniversity.com>
|
||||
*/
|
||||
class ServiceRouterLoader extends ObjectRouteLoader
|
||||
|
||||
@@ -63,7 +63,7 @@ abstract class ObjectRouteLoader extends Loader
|
||||
throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
|
||||
}
|
||||
|
||||
if (!\is_callable(array($loaderObject, $method))) {
|
||||
if (!\is_callable([$loaderObject, $method])) {
|
||||
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class PhpFileLoader extends FileLoader
|
||||
|
||||
if (\is_object($result) && \is_callable($result)) {
|
||||
$collection = new RouteCollection();
|
||||
$result(new RoutingConfigurator($collection, $this, $path, $file), $this);
|
||||
$result(new RoutingConfigurator($collection, $this, $path, $file));
|
||||
} else {
|
||||
$collection = $result;
|
||||
}
|
||||
|
||||
21
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
21
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
@@ -171,7 +171,7 @@ class XmlFileLoader extends FileLoader
|
||||
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
|
||||
|
||||
if (!\is_array($imported)) {
|
||||
$imported = array($imported);
|
||||
$imported = [$imported];
|
||||
}
|
||||
|
||||
foreach ($imported as $subCollection) {
|
||||
@@ -261,13 +261,14 @@ class XmlFileLoader extends FileLoader
|
||||
*/
|
||||
private function parseConfigs(\DOMElement $node, $path)
|
||||
{
|
||||
$defaults = array();
|
||||
$requirements = array();
|
||||
$options = array();
|
||||
$defaults = [];
|
||||
$requirements = [];
|
||||
$options = [];
|
||||
$condition = null;
|
||||
$prefixes = array();
|
||||
$paths = array();
|
||||
$prefixes = [];
|
||||
$paths = [];
|
||||
|
||||
/** @var \DOMElement $n */
|
||||
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
|
||||
if ($node !== $n->parentNode) {
|
||||
continue;
|
||||
@@ -292,7 +293,7 @@ class XmlFileLoader extends FileLoader
|
||||
$requirements[$n->getAttribute('key')] = trim($n->textContent);
|
||||
break;
|
||||
case 'option':
|
||||
$options[$n->getAttribute('key')] = trim($n->textContent);
|
||||
$options[$n->getAttribute('key')] = XmlUtils::phpize(trim($n->textContent));
|
||||
break;
|
||||
case 'condition':
|
||||
$condition = trim($n->textContent);
|
||||
@@ -312,7 +313,7 @@ class XmlFileLoader extends FileLoader
|
||||
$defaults['_controller'] = $controller;
|
||||
}
|
||||
|
||||
return array($defaults, $requirements, $options, $condition, $paths, $prefixes);
|
||||
return [$defaults, $requirements, $options, $condition, $paths, $prefixes];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,7 +377,7 @@ class XmlFileLoader extends FileLoader
|
||||
case 'string':
|
||||
return trim($node->nodeValue);
|
||||
case 'list':
|
||||
$list = array();
|
||||
$list = [];
|
||||
|
||||
foreach ($node->childNodes as $element) {
|
||||
if (!$element instanceof \DOMElement) {
|
||||
@@ -392,7 +393,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
return $list;
|
||||
case 'map':
|
||||
$map = array();
|
||||
$map = [];
|
||||
|
||||
foreach ($node->childNodes as $element) {
|
||||
if (!$element instanceof \DOMElement) {
|
||||
|
||||
24
vendor/symfony/routing/Loader/YamlFileLoader.php
vendored
24
vendor/symfony/routing/Loader/YamlFileLoader.php
vendored
@@ -27,9 +27,9 @@ use Symfony\Component\Yaml\Yaml;
|
||||
*/
|
||||
class YamlFileLoader extends FileLoader
|
||||
{
|
||||
private static $availableKeys = array(
|
||||
private static $availableKeys = [
|
||||
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', 'name_prefix', 'trailing_slash_on_root',
|
||||
);
|
||||
];
|
||||
private $yamlParser;
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,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), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,12 +108,12 @@ class YamlFileLoader extends FileLoader
|
||||
*/
|
||||
protected function parseRoute(RouteCollection $collection, $name, array $config, $path)
|
||||
{
|
||||
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
||||
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
||||
$options = isset($config['options']) ? $config['options'] : array();
|
||||
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
|
||||
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
|
||||
$options = isset($config['options']) ? $config['options'] : [];
|
||||
$host = isset($config['host']) ? $config['host'] : '';
|
||||
$schemes = isset($config['schemes']) ? $config['schemes'] : array();
|
||||
$methods = isset($config['methods']) ? $config['methods'] : array();
|
||||
$schemes = isset($config['schemes']) ? $config['schemes'] : [];
|
||||
$methods = isset($config['methods']) ? $config['methods'] : [];
|
||||
$condition = isset($config['condition']) ? $config['condition'] : null;
|
||||
|
||||
foreach ($requirements as $placeholder => $requirement) {
|
||||
@@ -154,9 +154,9 @@ class YamlFileLoader extends FileLoader
|
||||
{
|
||||
$type = isset($config['type']) ? $config['type'] : null;
|
||||
$prefix = isset($config['prefix']) ? $config['prefix'] : '';
|
||||
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
||||
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
||||
$options = isset($config['options']) ? $config['options'] : array();
|
||||
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
|
||||
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
|
||||
$options = isset($config['options']) ? $config['options'] : [];
|
||||
$host = isset($config['host']) ? $config['host'] : null;
|
||||
$condition = isset($config['condition']) ? $config['condition'] : null;
|
||||
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
|
||||
@@ -172,7 +172,7 @@ class YamlFileLoader extends FileLoader
|
||||
$imported = $this->import($config['resource'], $type, false, $file);
|
||||
|
||||
if (!\is_array($imported)) {
|
||||
$imported = array($imported);
|
||||
$imported = [$imported];
|
||||
}
|
||||
|
||||
foreach ($imported as $subCollection) {
|
||||
|
||||
@@ -28,7 +28,7 @@ interface MatcherDumperInterface
|
||||
*
|
||||
* @return string Executable code
|
||||
*/
|
||||
public function dump(array $options = array());
|
||||
public function dump(array $options = []);
|
||||
|
||||
/**
|
||||
* Gets the routes to dump.
|
||||
|
||||
@@ -32,7 +32,7 @@ class PhpMatcherDumper extends MatcherDumper
|
||||
/**
|
||||
* @var ExpressionFunctionProviderInterface[]
|
||||
*/
|
||||
private $expressionLanguageProviders = array();
|
||||
private $expressionLanguageProviders = [];
|
||||
|
||||
/**
|
||||
* Dumps a set of routes to a PHP class.
|
||||
@@ -46,12 +46,12 @@ class PhpMatcherDumper extends MatcherDumper
|
||||
*
|
||||
* @return string A PHP class representing the matcher class
|
||||
*/
|
||||
public function dump(array $options = array())
|
||||
public function dump(array $options = [])
|
||||
{
|
||||
$options = array_replace(array(
|
||||
$options = array_replace([
|
||||
'class' => 'ProjectUrlMatcher',
|
||||
'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
|
||||
), $options);
|
||||
], $options);
|
||||
|
||||
// trailing slash support is only enabled if we know how to redirect the user
|
||||
$interfaces = class_implements($options['base_class']);
|
||||
@@ -98,7 +98,7 @@ EOF;
|
||||
$host = '/'.strtr(strrev($host), '}.{', '(/)');
|
||||
}
|
||||
|
||||
$routes->addRoute($host ?: '/(.*)', array($name, $route));
|
||||
$routes->addRoute($host ?: '/(.*)', [$name, $route]);
|
||||
}
|
||||
|
||||
if ($matchHost) {
|
||||
@@ -111,7 +111,7 @@ EOF;
|
||||
|
||||
list($staticRoutes, $dynamicRoutes) = $this->groupStaticRoutes($routes);
|
||||
|
||||
$conditions = array(null);
|
||||
$conditions = [null];
|
||||
$code .= $this->compileStaticRoutes($staticRoutes, $conditions);
|
||||
$chunkLimit = \count($dynamicRoutes);
|
||||
|
||||
@@ -154,11 +154,12 @@ EOF;
|
||||
*/
|
||||
private function groupStaticRoutes(RouteCollection $collection): array
|
||||
{
|
||||
$staticRoutes = $dynamicRegex = array();
|
||||
$staticRoutes = $dynamicRegex = [];
|
||||
$dynamicRoutes = new RouteCollection();
|
||||
|
||||
foreach ($collection->all() as $name => $route) {
|
||||
$compiledRoute = $route->compile();
|
||||
$staticPrefix = rtrim($compiledRoute->getStaticPrefix(), '/');
|
||||
$hostRegex = $compiledRoute->getHostRegex();
|
||||
$regex = $compiledRoute->getRegex();
|
||||
if ($hasTrailingSlash = '/' !== $route->getPath()) {
|
||||
@@ -173,22 +174,22 @@ EOF;
|
||||
if ($hasTrailingSlash) {
|
||||
$url = substr($url, 0, -1);
|
||||
}
|
||||
foreach ($dynamicRegex as list($hostRx, $rx)) {
|
||||
if (preg_match($rx, $url) && (!$host || !$hostRx || preg_match($hostRx, $host))) {
|
||||
$dynamicRegex[] = array($hostRegex, $regex);
|
||||
foreach ($dynamicRegex as list($hostRx, $rx, $prefix)) {
|
||||
if (('' === $prefix || 0 === strpos($url, $prefix)) && preg_match($rx, $url) && (!$host || !$hostRx || preg_match($hostRx, $host))) {
|
||||
$dynamicRegex[] = [$hostRegex, $regex, $staticPrefix];
|
||||
$dynamicRoutes->add($name, $route);
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$staticRoutes[$url][$name] = array($route, $hasTrailingSlash);
|
||||
$staticRoutes[$url][$name] = [$route, $hasTrailingSlash];
|
||||
} else {
|
||||
$dynamicRegex[] = array($hostRegex, $regex);
|
||||
$dynamicRegex[] = [$hostRegex, $regex, $staticPrefix];
|
||||
$dynamicRoutes->add($name, $route);
|
||||
}
|
||||
}
|
||||
|
||||
return array($staticRoutes, $dynamicRoutes);
|
||||
return [$staticRoutes, $dynamicRoutes];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,15 +208,15 @@ EOF;
|
||||
$code = '';
|
||||
|
||||
foreach ($staticRoutes as $url => $routes) {
|
||||
$code .= self::export($url)." => array(\n";
|
||||
$code .= self::export($url)." => [\n";
|
||||
foreach ($routes as $name => list($route, $hasTrailingSlash)) {
|
||||
$code .= $this->compileRoute($route, $name, !$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex() ?: null, $hasTrailingSlash, false, $conditions);
|
||||
$code .= $this->compileRoute($route, $name, (!$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex()) ?: null, $hasTrailingSlash, false, $conditions);
|
||||
}
|
||||
$code .= "),\n";
|
||||
$code .= "],\n";
|
||||
}
|
||||
|
||||
if ($code) {
|
||||
return "\$this->staticRoutes = array(\n{$this->indent($code, 1)});\n";
|
||||
return "\$this->staticRoutes = [\n{$this->indent($code, 1)}];\n";
|
||||
}
|
||||
|
||||
return $code;
|
||||
@@ -245,14 +246,14 @@ EOF;
|
||||
return '';
|
||||
}
|
||||
$code = '';
|
||||
$state = (object) array(
|
||||
$state = (object) [
|
||||
'regex' => '',
|
||||
'routes' => '',
|
||||
'mark' => 0,
|
||||
'markTail' => 0,
|
||||
'hostVars' => array(),
|
||||
'vars' => array(),
|
||||
);
|
||||
'hostVars' => [],
|
||||
'vars' => [],
|
||||
];
|
||||
$state->getVars = static function ($m) use ($state) {
|
||||
if ('_route' === $m[1]) {
|
||||
return '?:';
|
||||
@@ -265,13 +266,13 @@ EOF;
|
||||
|
||||
$chunkSize = 0;
|
||||
$prev = null;
|
||||
$perModifiers = array();
|
||||
$perModifiers = [];
|
||||
foreach ($collection->all() as $name => $route) {
|
||||
preg_match('#[a-zA-Z]*$#', $route->compile()->getRegex(), $rx);
|
||||
if ($chunkLimit < ++$chunkSize || $prev !== $rx[0] && $route->compile()->getPathVariables()) {
|
||||
$chunkSize = 1;
|
||||
$routes = new RouteCollection();
|
||||
$perModifiers[] = array($rx[0], $routes);
|
||||
$perModifiers[] = [$rx[0], $routes];
|
||||
$prev = $rx[0];
|
||||
}
|
||||
$routes->add($name, $route);
|
||||
@@ -279,12 +280,12 @@ EOF;
|
||||
|
||||
foreach ($perModifiers as list($modifiers, $routes)) {
|
||||
$prev = false;
|
||||
$perHost = array();
|
||||
$perHost = [];
|
||||
foreach ($routes->all() as $name => $route) {
|
||||
$regex = $route->compile()->getHostRegex();
|
||||
if ($prev !== $regex) {
|
||||
$routes = new RouteCollection();
|
||||
$perHost[] = array($regex, $routes);
|
||||
$perHost[] = [$regex, $routes];
|
||||
$prev = $regex;
|
||||
}
|
||||
$routes->add($name, $route);
|
||||
@@ -299,12 +300,12 @@ EOF;
|
||||
if ($matchHost) {
|
||||
if ($hostRegex) {
|
||||
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#', $hostRegex, $rx);
|
||||
$state->vars = array();
|
||||
$state->vars = [];
|
||||
$hostRegex = '(?i:'.preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]).')\.';
|
||||
$state->hostVars = $state->vars;
|
||||
} else {
|
||||
$hostRegex = '(?:(?:[^./]*+\.)++)';
|
||||
$state->hostVars = array();
|
||||
$state->hostVars = [];
|
||||
}
|
||||
$state->mark += \strlen($rx = ($prev ? ')' : '')."|{$hostRegex}(?");
|
||||
$code .= "\n .".self::export($rx);
|
||||
@@ -316,14 +317,14 @@ EOF;
|
||||
foreach ($routes->all() as $name => $route) {
|
||||
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#', $route->compile()->getRegex(), $rx);
|
||||
|
||||
$state->vars = array();
|
||||
$state->vars = [];
|
||||
$regex = preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]);
|
||||
if ($hasTrailingSlash = '/' !== $regex && '/' === $regex[-1]) {
|
||||
$regex = substr($regex, 0, -1);
|
||||
}
|
||||
$hasTrailingVar = (bool) preg_match('#\{\w+\}/?$#', $route->getPath());
|
||||
|
||||
$tree->addRoute($regex, array($name, $regex, $state->vars, $route, $hasTrailingSlash, $hasTrailingVar));
|
||||
$tree->addRoute($regex, [$name, $regex, $state->vars, $route, $hasTrailingSlash, $hasTrailingVar]);
|
||||
}
|
||||
|
||||
$code .= $this->compileStaticPrefixCollection($tree, $state, 0, $conditions);
|
||||
@@ -348,8 +349,8 @@ EOF;
|
||||
|
||||
unset($state->getVars);
|
||||
|
||||
return "\$this->regexpList = array({$code}\n);\n"
|
||||
."\$this->dynamicRoutes = array(\n{$this->indent($state->routes, 1)});\n";
|
||||
return "\$this->regexpList = [{$code}\n];\n"
|
||||
."\$this->dynamicRoutes = [\n{$this->indent($state->routes, 1)}];\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,7 +395,7 @@ EOF;
|
||||
$state->regex .= $rx;
|
||||
|
||||
$prevRegex = $compiledRoute->getRegex();
|
||||
$state->routes .= sprintf("%s => array(\n%s),\n", $state->mark, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $hasTrailingVar, $conditions));
|
||||
$state->routes .= sprintf("%s => [\n%s],\n", $state->mark, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $hasTrailingVar, $conditions));
|
||||
}
|
||||
|
||||
return $code;
|
||||
@@ -413,15 +414,15 @@ EOF;
|
||||
}
|
||||
|
||||
if ($condition = $route->getCondition()) {
|
||||
$condition = $this->getExpressionLanguage()->compile($condition, array('context', 'request'));
|
||||
$condition = $this->getExpressionLanguage()->compile($condition, ['context', 'request']);
|
||||
$condition = $conditions[$condition] ?? $conditions[$condition] = (false !== strpos($condition, '$request') ? 1 : -1) * \count($conditions);
|
||||
} else {
|
||||
$condition = 'null';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
" array(%s, %s, %s, %s, %s, %s, %s),\n",
|
||||
self::export(array('_route' => $name) + $defaults),
|
||||
" [%s, %s, %s, %s, %s, %s, %s],\n",
|
||||
self::export(['_route' => $name] + $defaults),
|
||||
self::export($vars),
|
||||
self::export(array_flip($route->getMethods()) ?: null),
|
||||
self::export(array_flip($route->getSchemes()) ?: null),
|
||||
@@ -445,7 +446,7 @@ EOF;
|
||||
|
||||
private function indent($code, $level = 1)
|
||||
{
|
||||
$code = preg_replace('/ => array\(\n (array\(.+),\n\),/', ' => array($1),', $code);
|
||||
$code = preg_replace('/ => \[\n (\[.+),\n\],/', ' => [$1],', $code);
|
||||
|
||||
return preg_replace('/^./m', str_repeat(' ', $level).'$0', $code);
|
||||
}
|
||||
@@ -466,11 +467,11 @@ EOF;
|
||||
return str_replace("\n", '\'."\n".\'', var_export($value, true));
|
||||
}
|
||||
if (!$value) {
|
||||
return 'array()';
|
||||
return '[]';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$export = 'array(';
|
||||
$export = '[';
|
||||
|
||||
foreach ($value as $k => $v) {
|
||||
if ($i === $k) {
|
||||
@@ -486,6 +487,6 @@ EOF;
|
||||
$export .= self::export($v).', ';
|
||||
}
|
||||
|
||||
return substr_replace($export, ')', -2);
|
||||
return substr_replace($export, ']', -2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,23 +15,26 @@ use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\NoConfigurationException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @property RequestContext $context
|
||||
*/
|
||||
trait PhpMatcherTrait
|
||||
{
|
||||
private $matchHost = false;
|
||||
private $staticRoutes = array();
|
||||
private $regexpList = array();
|
||||
private $dynamicRoutes = array();
|
||||
private $staticRoutes = [];
|
||||
private $regexpList = [];
|
||||
private $dynamicRoutes = [];
|
||||
private $checkCondition;
|
||||
|
||||
public function match($pathinfo)
|
||||
{
|
||||
$allow = $allowSchemes = array();
|
||||
$allow = $allowSchemes = [];
|
||||
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
|
||||
return $ret;
|
||||
}
|
||||
@@ -41,7 +44,7 @@ trait PhpMatcherTrait
|
||||
if (!$this instanceof RedirectableUrlMatcherInterface) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
if (!\in_array($this->context->getMethod(), array('HEAD', 'GET'), true)) {
|
||||
if (!\in_array($this->context->getMethod(), ['HEAD', 'GET'], true)) {
|
||||
// no-op
|
||||
} elseif ($allowSchemes) {
|
||||
redirect_scheme:
|
||||
@@ -67,9 +70,9 @@ trait PhpMatcherTrait
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
private function doMatch(string $pathinfo, array &$allow = array(), array &$allowSchemes = array()): array
|
||||
private function doMatch(string $pathinfo, array &$allow = [], array &$allowSchemes = []): array
|
||||
{
|
||||
$allow = $allowSchemes = array();
|
||||
$allow = $allowSchemes = [];
|
||||
$pathinfo = rawurldecode($pathinfo) ?: '/';
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';
|
||||
$context = $this->context;
|
||||
@@ -84,18 +87,11 @@ trait PhpMatcherTrait
|
||||
}
|
||||
$supportsRedirections = 'GET' === $canonicalMethod && $this instanceof RedirectableUrlMatcherInterface;
|
||||
|
||||
foreach ($this->staticRoutes[$trimmedPathinfo] ?? array() as list($ret, $requiredHost, $requiredMethods, $requiredSchemes, $hasTrailingSlash, , $condition)) {
|
||||
foreach ($this->staticRoutes[$trimmedPathinfo] ?? [] as list($ret, $requiredHost, $requiredMethods, $requiredSchemes, $hasTrailingSlash, , $condition)) {
|
||||
if ($condition && !($this->checkCondition)($condition, $context, 0 < $condition ? $request ?? $request = $this->request ?: $this->createRequest($pathinfo) : null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
|
||||
if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) {
|
||||
return $allow = $allowSchemes = array();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($requiredHost) {
|
||||
if ('#' !== $requiredHost[0] ? $requiredHost !== $host : !preg_match($requiredHost, $host, $hostMatches)) {
|
||||
continue;
|
||||
@@ -106,6 +102,13 @@ trait PhpMatcherTrait
|
||||
}
|
||||
}
|
||||
|
||||
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
|
||||
if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) {
|
||||
return $allow = $allowSchemes = [];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
|
||||
if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
|
||||
if ($hasRequiredScheme) {
|
||||
@@ -113,6 +116,7 @@ trait PhpMatcherTrait
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$hasRequiredScheme) {
|
||||
$allowSchemes += $requiredSchemes;
|
||||
continue;
|
||||
@@ -130,21 +134,21 @@ trait PhpMatcherTrait
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar) {
|
||||
// no-op
|
||||
} elseif (preg_match($regex, $this->matchHost ? $host.'.'.$trimmedPathinfo : $trimmedPathinfo, $n) && $m === (int) $n['MARK']) {
|
||||
$matches = $n;
|
||||
} else {
|
||||
$hasTrailingSlash = true;
|
||||
$hasTrailingVar = $trimmedPathinfo !== $pathinfo && $hasTrailingVar;
|
||||
|
||||
if ($hasTrailingVar && ($hasTrailingSlash || (null === $n = $matches[\count($vars)] ?? null) || '/' !== ($n[-1] ?? '/')) && preg_match($regex, $this->matchHost ? $host.'.'.$trimmedPathinfo : $trimmedPathinfo, $n) && $m === (int) $n['MARK']) {
|
||||
if ($hasTrailingSlash) {
|
||||
$matches = $n;
|
||||
} else {
|
||||
$hasTrailingVar = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
|
||||
if ('/' !== $pathinfo && !$hasTrailingVar && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
|
||||
if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) {
|
||||
return $allow = $allowSchemes = array();
|
||||
}
|
||||
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar) {
|
||||
continue;
|
||||
return $allow = $allowSchemes = [];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($vars as $i => $v) {
|
||||
@@ -177,6 +181,6 @@ trait PhpMatcherTrait
|
||||
throw new NoConfigurationException();
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,17 +28,17 @@ class StaticPrefixCollection
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $staticPrefixes = array();
|
||||
private $staticPrefixes = [];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $prefixes = array();
|
||||
private $prefixes = [];
|
||||
|
||||
/**
|
||||
* @var array[]|self[]
|
||||
*/
|
||||
private $items = array();
|
||||
private $items = [];
|
||||
|
||||
public function __construct(string $prefix = '/')
|
||||
{
|
||||
@@ -106,7 +106,7 @@ class StaticPrefixCollection
|
||||
$child = new self($commonPrefix);
|
||||
list($child->prefixes[0], $child->staticPrefixes[0]) = $child->getCommonPrefix($this->prefixes[$i], $this->prefixes[$i]);
|
||||
list($child->prefixes[1], $child->staticPrefixes[1]) = $child->getCommonPrefix($prefix, $prefix);
|
||||
$child->items = array($this->items[$i], $route);
|
||||
$child->items = [$this->items[$i], $route];
|
||||
|
||||
$this->staticPrefixes[$i] = $commonStaticPrefix;
|
||||
$this->prefixes[$i] = $commonPrefix;
|
||||
@@ -149,7 +149,7 @@ class StaticPrefixCollection
|
||||
$baseLength = \strlen($this->prefix);
|
||||
$end = min(\strlen($prefix), \strlen($anotherPrefix));
|
||||
$staticLength = null;
|
||||
set_error_handler(array(__CLASS__, 'handleError'));
|
||||
set_error_handler([__CLASS__, 'handleError']);
|
||||
|
||||
for ($i = $baseLength; $i < $end && $prefix[$i] === $anotherPrefix[$i]; ++$i) {
|
||||
if ('(' === $prefix[$i]) {
|
||||
@@ -192,7 +192,7 @@ class StaticPrefixCollection
|
||||
} while (0b10 === (\ord($prefix[$i]) >> 6));
|
||||
}
|
||||
|
||||
return array(substr($prefix, 0, $i), substr($prefix, 0, $staticLength ?? $i));
|
||||
return [substr($prefix, 0, $i), substr($prefix, 0, $staticLength ?? $i)];
|
||||
}
|
||||
|
||||
public static function handleError($type, $msg)
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable
|
||||
try {
|
||||
return parent::match($pathinfo);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
if (!\in_array($this->context->getMethod(), array('HEAD', 'GET'), true)) {
|
||||
if (!\in_array($this->context->getMethod(), ['HEAD', 'GET'], true)) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class TraceableUrlMatcher extends UrlMatcher
|
||||
|
||||
public function getTraces($pathinfo)
|
||||
{
|
||||
$this->traces = array();
|
||||
$this->traces = [];
|
||||
|
||||
try {
|
||||
$this->match($pathinfo);
|
||||
@@ -57,7 +57,7 @@ class TraceableUrlMatcher extends UrlMatcher
|
||||
|
||||
if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) {
|
||||
// does it match without any requirements?
|
||||
$r = new Route($route->getPath(), $route->getDefaults(), array(), $route->getOptions());
|
||||
$r = new Route($route->getPath(), $route->getDefaults(), [], $route->getOptions());
|
||||
$cr = $r->compile();
|
||||
if (!preg_match($cr->getRegex(), $pathinfo)) {
|
||||
$this->addTrace(sprintf('Path "%s" does not match', $route->getPath()), self::ROUTE_DOES_NOT_MATCH, $name, $route);
|
||||
@@ -66,7 +66,7 @@ class TraceableUrlMatcher extends UrlMatcher
|
||||
}
|
||||
|
||||
foreach ($route->getRequirements() as $n => $regex) {
|
||||
$r = new Route($route->getPath(), $route->getDefaults(), array($n => $regex), $route->getOptions());
|
||||
$r = new Route($route->getPath(), $route->getDefaults(), [$n => $regex], $route->getOptions());
|
||||
$cr = $r->compile();
|
||||
|
||||
if (\in_array($n, $cr->getVariables()) && !preg_match($cr->getRegex(), $pathinfo)) {
|
||||
@@ -80,7 +80,7 @@ class TraceableUrlMatcher extends UrlMatcher
|
||||
}
|
||||
|
||||
// check host requirement
|
||||
$hostMatches = array();
|
||||
$hostMatches = [];
|
||||
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
|
||||
$this->addTrace(sprintf('Host "%s" does not match the requirement ("%s")', $this->context->getHost(), $route->getHost()), 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 ?: $this->createRequest($pathinfo)))) {
|
||||
if (!$this->getExpressionLanguage()->evaluate($condition, ['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;
|
||||
@@ -131,11 +131,11 @@ class TraceableUrlMatcher extends UrlMatcher
|
||||
|
||||
private function addTrace($log, $level = self::ROUTE_DOES_NOT_MATCH, $name = null, $route = null)
|
||||
{
|
||||
$this->traces[] = array(
|
||||
$this->traces[] = [
|
||||
'log' => $log,
|
||||
'name' => $name,
|
||||
'level' => $level,
|
||||
'path' => null !== $route ? $route->getPath() : null,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
52
vendor/symfony/routing/Matcher/UrlMatcher.php
vendored
52
vendor/symfony/routing/Matcher/UrlMatcher.php
vendored
@@ -32,19 +32,20 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
const REQUIREMENT_MISMATCH = 1;
|
||||
const ROUTE_MATCH = 2;
|
||||
|
||||
/** @var RequestContext */
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* Collects HTTP methods that would be allowed for the request.
|
||||
*/
|
||||
protected $allow = array();
|
||||
protected $allow = [];
|
||||
|
||||
/**
|
||||
* Collects URI schemes that would be allowed for the request.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected $allowSchemes = array();
|
||||
protected $allowSchemes = [];
|
||||
|
||||
protected $routes;
|
||||
protected $request;
|
||||
@@ -53,7 +54,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
/**
|
||||
* @var ExpressionFunctionProviderInterface[]
|
||||
*/
|
||||
protected $expressionLanguageProviders = array();
|
||||
protected $expressionLanguageProviders = [];
|
||||
|
||||
public function __construct(RouteCollection $routes, RequestContext $context)
|
||||
{
|
||||
@@ -82,7 +83,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
*/
|
||||
public function match($pathinfo)
|
||||
{
|
||||
$this->allow = $this->allowSchemes = array();
|
||||
$this->allow = $this->allowSchemes = [];
|
||||
|
||||
if ($ret = $this->matchCollection(rawurldecode($pathinfo) ?: '/', $this->routes)) {
|
||||
return $ret;
|
||||
@@ -156,24 +157,17 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar = preg_match('#\{\w+\}/?$#', $route->getPath())) {
|
||||
// no-op
|
||||
} elseif (preg_match($regex, $trimmedPathinfo, $m)) {
|
||||
$matches = $m;
|
||||
} else {
|
||||
$hasTrailingSlash = true;
|
||||
}
|
||||
$hasTrailingVar = $trimmedPathinfo !== $pathinfo && preg_match('#\{\w+\}/?$#', $route->getPath());
|
||||
|
||||
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
|
||||
if ($supportsTrailingSlash && (!$requiredMethods || \in_array('GET', $requiredMethods))) {
|
||||
return $this->allow = $this->allowSchemes = array();
|
||||
}
|
||||
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar) {
|
||||
continue;
|
||||
if ($hasTrailingVar && ($hasTrailingSlash || (null === $m = $matches[\count($compiledRoute->getPathVariables())] ?? null) || '/' !== ($m[-1] ?? '/')) && preg_match($regex, $trimmedPathinfo, $m)) {
|
||||
if ($hasTrailingSlash) {
|
||||
$matches = $m;
|
||||
} else {
|
||||
$hasTrailingVar = false;
|
||||
}
|
||||
}
|
||||
|
||||
$hostMatches = array();
|
||||
$hostMatches = [];
|
||||
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
|
||||
continue;
|
||||
}
|
||||
@@ -184,6 +178,14 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('/' !== $pathinfo && !$hasTrailingVar && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
|
||||
if ($supportsTrailingSlash && (!$requiredMethods || \in_array('GET', $requiredMethods))) {
|
||||
return $this->allow = $this->allowSchemes = [];
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$hasRequiredScheme = !$route->getSchemes() || $route->hasScheme($this->context->getScheme());
|
||||
if ($requiredMethods) {
|
||||
if (!\in_array($method, $requiredMethods)) {
|
||||
@@ -201,10 +203,10 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, isset($status[1]) ? $status[1] : array()));
|
||||
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, isset($status[1]) ? $status[1] : []));
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,11 +246,11 @@ 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 ?: $this->createRequest($pathinfo)))) {
|
||||
return array(self::REQUIREMENT_MISMATCH, null);
|
||||
if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), ['context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)])) {
|
||||
return [self::REQUIREMENT_MISMATCH, null];
|
||||
}
|
||||
|
||||
return array(self::REQUIREMENT_MATCH, null);
|
||||
return [self::REQUIREMENT_MATCH, null];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,9 +293,9 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
return Request::create($this->context->getScheme().'://'.$this->context->getHost().$this->context->getBaseUrl().$pathinfo, $this->context->getMethod(), $this->context->getParameters(), array(), array(), array(
|
||||
return Request::create($this->context->getScheme().'://'.$this->context->getHost().$this->context->getBaseUrl().$pathinfo, $this->context->getMethod(), $this->context->getParameters(), [], [], [
|
||||
'SCRIPT_FILENAME' => $this->context->getBaseUrl(),
|
||||
'SCRIPT_NAME' => $this->context->getBaseUrl(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
4
vendor/symfony/routing/RequestContext.php
vendored
4
vendor/symfony/routing/RequestContext.php
vendored
@@ -31,7 +31,7 @@ class RequestContext
|
||||
private $httpPort;
|
||||
private $httpsPort;
|
||||
private $queryString;
|
||||
private $parameters = array();
|
||||
private $parameters = [];
|
||||
|
||||
public function __construct(string $baseUrl = '', string $method = 'GET', string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443, string $path = '/', string $queryString = '')
|
||||
{
|
||||
@@ -306,7 +306,7 @@ class RequestContext
|
||||
*/
|
||||
public function hasParameter($name)
|
||||
{
|
||||
return array_key_exists($name, $this->parameters);
|
||||
return \array_key_exists($name, $this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
30
vendor/symfony/routing/Route.php
vendored
30
vendor/symfony/routing/Route.php
vendored
@@ -21,11 +21,11 @@ class Route implements \Serializable
|
||||
{
|
||||
private $path = '/';
|
||||
private $host = '';
|
||||
private $schemes = array();
|
||||
private $methods = array();
|
||||
private $defaults = array();
|
||||
private $requirements = array();
|
||||
private $options = array();
|
||||
private $schemes = [];
|
||||
private $methods = [];
|
||||
private $defaults = [];
|
||||
private $requirements = [];
|
||||
private $options = [];
|
||||
private $condition = '';
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ class Route implements \Serializable
|
||||
* @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(string $path, array $defaults = array(), array $requirements = array(), array $options = array(), ?string $host = '', $schemes = array(), $methods = array(), ?string $condition = '')
|
||||
public function __construct(string $path, array $defaults = [], array $requirements = [], array $options = [], ?string $host = '', $schemes = [], $methods = [], ?string $condition = '')
|
||||
{
|
||||
$this->setPath($path);
|
||||
$this->addDefaults($defaults);
|
||||
@@ -67,7 +67,7 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return serialize(array(
|
||||
return serialize([
|
||||
'path' => $this->path,
|
||||
'host' => $this->host,
|
||||
'defaults' => $this->defaults,
|
||||
@@ -77,7 +77,7 @@ class Route implements \Serializable
|
||||
'methods' => $this->methods,
|
||||
'condition' => $this->condition,
|
||||
'compiled' => $this->compiled,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,9 +262,9 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
$this->options = array(
|
||||
$this->options = [
|
||||
'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler',
|
||||
);
|
||||
];
|
||||
|
||||
return $this->addOptions($options);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function hasOption($name)
|
||||
{
|
||||
return array_key_exists($name, $this->options);
|
||||
return \array_key_exists($name, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,7 +351,7 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function setDefaults(array $defaults)
|
||||
{
|
||||
$this->defaults = array();
|
||||
$this->defaults = [];
|
||||
|
||||
return $this->addDefaults($defaults);
|
||||
}
|
||||
@@ -396,7 +396,7 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function hasDefault($name)
|
||||
{
|
||||
return array_key_exists($name, $this->defaults);
|
||||
return \array_key_exists($name, $this->defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,7 +436,7 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function setRequirements(array $requirements)
|
||||
{
|
||||
$this->requirements = array();
|
||||
$this->requirements = [];
|
||||
|
||||
return $this->addRequirements($requirements);
|
||||
}
|
||||
@@ -481,7 +481,7 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function hasRequirement($key)
|
||||
{
|
||||
return array_key_exists($key, $this->requirements);
|
||||
return \array_key_exists($key, $this->requirements);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
vendor/symfony/routing/RouteCollection.php
vendored
10
vendor/symfony/routing/RouteCollection.php
vendored
@@ -28,12 +28,12 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* @var Route[]
|
||||
*/
|
||||
private $routes = array();
|
||||
private $routes = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $resources = array();
|
||||
private $resources = [];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -138,7 +138,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* @param array $defaults An array of default values
|
||||
* @param array $requirements An array of requirements
|
||||
*/
|
||||
public function addPrefix($prefix, array $defaults = array(), array $requirements = array())
|
||||
public function addPrefix($prefix, array $defaults = [], array $requirements = [])
|
||||
{
|
||||
$prefix = trim(trim($prefix), '/');
|
||||
|
||||
@@ -158,7 +158,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function addNamePrefix(string $prefix)
|
||||
{
|
||||
$prefixedRoutes = array();
|
||||
$prefixedRoutes = [];
|
||||
|
||||
foreach ($this->routes as $name => $route) {
|
||||
$prefixedRoutes[$prefix.$name] = $route;
|
||||
@@ -177,7 +177,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* @param array $defaults An array of default values
|
||||
* @param array $requirements An array of requirements
|
||||
*/
|
||||
public function setHost($pattern, array $defaults = array(), array $requirements = array())
|
||||
public function setHost($pattern, array $defaults = [], array $requirements = [])
|
||||
{
|
||||
foreach ($this->routes as $route) {
|
||||
$route->setHost($pattern);
|
||||
|
||||
@@ -25,18 +25,18 @@ class RouteCollectionBuilder
|
||||
/**
|
||||
* @var Route[]|RouteCollectionBuilder[]
|
||||
*/
|
||||
private $routes = array();
|
||||
private $routes = [];
|
||||
|
||||
private $loader;
|
||||
private $defaults = array();
|
||||
private $defaults = [];
|
||||
private $prefix;
|
||||
private $host;
|
||||
private $condition;
|
||||
private $requirements = array();
|
||||
private $options = array();
|
||||
private $requirements = [];
|
||||
private $options = [];
|
||||
private $schemes;
|
||||
private $methods;
|
||||
private $resources = array();
|
||||
private $resources = [];
|
||||
|
||||
public function __construct(LoaderInterface $loader = null)
|
||||
{
|
||||
@@ -330,7 +330,7 @@ class RouteCollectionBuilder
|
||||
$methods = implode('_', $route->getMethods()).'_';
|
||||
|
||||
$routeName = $methods.$route->getPath();
|
||||
$routeName = str_replace(array('/', ':', '|', '-'), '_', $routeName);
|
||||
$routeName = str_replace(['/', ':', '|', '-'], '_', $routeName);
|
||||
$routeName = preg_replace('/[^a-z0-9A-Z_.]+/', '', $routeName);
|
||||
|
||||
// Collapse consecutive underscores down into a single underscore.
|
||||
@@ -358,7 +358,7 @@ class RouteCollectionBuilder
|
||||
if ($this->loader->supports($resource, $type)) {
|
||||
$collections = $this->loader->load($resource, $type);
|
||||
|
||||
return \is_array($collections) ? $collections : array($collections);
|
||||
return \is_array($collections) ? $collections : [$collections];
|
||||
}
|
||||
|
||||
if (null === $resolver = $this->loader->getResolver()) {
|
||||
@@ -371,6 +371,6 @@ class RouteCollectionBuilder
|
||||
|
||||
$collections = $loader->load($resource, $type);
|
||||
|
||||
return \is_array($collections) ? $collections : array($collections);
|
||||
return \is_array($collections) ? $collections : [$collections];
|
||||
}
|
||||
}
|
||||
|
||||
26
vendor/symfony/routing/RouteCompiler.php
vendored
26
vendor/symfony/routing/RouteCompiler.php
vendored
@@ -46,10 +46,10 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
*/
|
||||
public static function compile(Route $route)
|
||||
{
|
||||
$hostVariables = array();
|
||||
$variables = array();
|
||||
$hostVariables = [];
|
||||
$variables = [];
|
||||
$hostRegex = null;
|
||||
$hostTokens = array();
|
||||
$hostTokens = [];
|
||||
|
||||
if ('' !== $host = $route->getHost()) {
|
||||
$result = self::compilePattern($route, $host, true);
|
||||
@@ -94,9 +94,9 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
|
||||
private static function compilePattern(Route $route, $pattern, $isHost)
|
||||
{
|
||||
$tokens = array();
|
||||
$variables = array();
|
||||
$matches = array();
|
||||
$tokens = [];
|
||||
$variables = [];
|
||||
$matches = [];
|
||||
$pos = 0;
|
||||
$defaultSeparator = $isHost ? '.' : '/';
|
||||
$useUtf8 = preg_match('//u', $pattern);
|
||||
@@ -142,9 +142,9 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
}
|
||||
|
||||
if ($isSeparator && $precedingText !== $precedingChar) {
|
||||
$tokens[] = array('text', substr($precedingText, 0, -\strlen($precedingChar)));
|
||||
$tokens[] = ['text', substr($precedingText, 0, -\strlen($precedingChar))];
|
||||
} elseif (!$isSeparator && \strlen($precedingText) > 0) {
|
||||
$tokens[] = array('text', $precedingText);
|
||||
$tokens[] = ['text', $precedingText];
|
||||
}
|
||||
|
||||
$regexp = $route->getRequirement($varName);
|
||||
@@ -153,7 +153,7 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
// Find the next static character after the variable that functions as a separator. By default, this separator and '/'
|
||||
// are disallowed for the variable. This default requirement makes sure that optional variables can be matched at all
|
||||
// and that the generating-matching-combination of URLs unambiguous, i.e. the params used for generating the URL are
|
||||
// the same that will be matched. Example: new Route('/{page}.{_format}', array('_format' => 'html'))
|
||||
// the same that will be matched. Example: new Route('/{page}.{_format}', ['_format' => 'html'])
|
||||
// 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'.
|
||||
@@ -183,12 +183,12 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$regexp = self::transformCapturingGroupsToNonCapturings($regexp);
|
||||
}
|
||||
|
||||
$tokens[] = array('variable', $isSeparator ? $precedingChar : '', $regexp, $varName);
|
||||
$tokens[] = ['variable', $isSeparator ? $precedingChar : '', $regexp, $varName];
|
||||
$variables[] = $varName;
|
||||
}
|
||||
|
||||
if ($pos < \strlen($pattern)) {
|
||||
$tokens[] = array('text', substr($pattern, $pos));
|
||||
$tokens[] = ['text', substr($pattern, $pos)];
|
||||
}
|
||||
|
||||
// find the first optional token
|
||||
@@ -221,12 +221,12 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'staticPrefix' => self::determineStaticPrefix($route, $tokens),
|
||||
'regex' => $regexp,
|
||||
'tokens' => array_reverse($tokens),
|
||||
'variables' => $variables,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
38
vendor/symfony/routing/Router.php
vendored
38
vendor/symfony/routing/Router.php
vendored
@@ -66,13 +66,18 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $options = array();
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* @var LoggerInterface|null
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $defaultLocale;
|
||||
|
||||
/**
|
||||
* @var ConfigCacheFactoryInterface|null
|
||||
*/
|
||||
@@ -81,7 +86,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
/**
|
||||
* @var ExpressionFunctionProviderInterface[]
|
||||
*/
|
||||
private $expressionLanguageProviders = array();
|
||||
private $expressionLanguageProviders = [];
|
||||
|
||||
/**
|
||||
* @param LoaderInterface $loader A LoaderInterface instance
|
||||
@@ -90,13 +95,14 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
* @param RequestContext $context The context
|
||||
* @param LoggerInterface $logger A logger instance
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader, $resource, array $options = array(), RequestContext $context = null, LoggerInterface $logger = null)
|
||||
public function __construct(LoaderInterface $loader, $resource, array $options = [], RequestContext $context = null, LoggerInterface $logger = null, string $defaultLocale = null)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->resource = $resource;
|
||||
$this->logger = $logger;
|
||||
$this->context = $context ?: new RequestContext();
|
||||
$this->setOptions($options);
|
||||
$this->defaultLocale = $defaultLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +130,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
$this->options = array(
|
||||
$this->options = [
|
||||
'cache_dir' => null,
|
||||
'debug' => false,
|
||||
'generator_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
|
||||
@@ -137,12 +143,12 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
'matcher_cache_class' => 'ProjectUrlMatcher',
|
||||
'resource_type' => null,
|
||||
'strict_requirements' => true,
|
||||
);
|
||||
];
|
||||
|
||||
// check option names and live merge, if errors are encountered Exception will be thrown
|
||||
$invalid = array();
|
||||
$invalid = [];
|
||||
foreach ($options as $key => $value) {
|
||||
if (array_key_exists($key, $this->options)) {
|
||||
if (\array_key_exists($key, $this->options)) {
|
||||
$this->options[$key] = $value;
|
||||
} else {
|
||||
$invalid[] = $key;
|
||||
@@ -164,7 +170,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
if (!array_key_exists($key, $this->options)) {
|
||||
if (!\array_key_exists($key, $this->options)) {
|
||||
throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
|
||||
}
|
||||
|
||||
@@ -182,7 +188,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
if (!array_key_exists($key, $this->options)) {
|
||||
if (!\array_key_exists($key, $this->options)) {
|
||||
throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
|
||||
}
|
||||
|
||||
@@ -235,7 +241,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
return $this->getGenerator()->generate($name, $parameters, $referenceType);
|
||||
}
|
||||
@@ -293,10 +299,10 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
}
|
||||
}
|
||||
|
||||
$options = array(
|
||||
$options = [
|
||||
'class' => $this->options['matcher_cache_class'],
|
||||
'base_class' => $this->options['matcher_base_class'],
|
||||
);
|
||||
];
|
||||
|
||||
$cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
|
||||
}
|
||||
@@ -321,16 +327,16 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
}
|
||||
|
||||
if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
|
||||
$this->generator = new $this->options['generator_class']($this->getRouteCollection(), $this->context, $this->logger);
|
||||
$this->generator = new $this->options['generator_class']($this->getRouteCollection(), $this->context, $this->logger, $this->defaultLocale);
|
||||
} else {
|
||||
$cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/'.$this->options['generator_cache_class'].'.php',
|
||||
function (ConfigCacheInterface $cache) {
|
||||
$dumper = $this->getGeneratorDumperInstance();
|
||||
|
||||
$options = array(
|
||||
$options = [
|
||||
'class' => $this->options['generator_cache_class'],
|
||||
'base_class' => $this->options['generator_base_class'],
|
||||
);
|
||||
];
|
||||
|
||||
$cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
|
||||
}
|
||||
@@ -340,7 +346,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
require_once $cache->getPath();
|
||||
}
|
||||
|
||||
$this->generator = new $this->options['generator_cache_class']($this->context, $this->logger);
|
||||
$this->generator = new $this->options['generator_cache_class']($this->context, $this->logger, $this->defaultLocale);
|
||||
}
|
||||
|
||||
if ($this->generator instanceof ConfigurableRequirementsInterface) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class RouteTest extends TestCase
|
||||
*/
|
||||
public function testInvalidRouteParameter()
|
||||
{
|
||||
$route = new Route(array('foo' => 'bar'));
|
||||
$route = new Route(['foo' => 'bar']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ class RouteTest extends TestCase
|
||||
*/
|
||||
public function testTryingToSetLocalesDirectly()
|
||||
{
|
||||
$route = new Route(array('locales' => array('nl' => 'bar')));
|
||||
$route = new Route(['locales' => ['nl' => 'bar']]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,23 +37,23 @@ class RouteTest extends TestCase
|
||||
*/
|
||||
public function testRouteParameters($parameter, $value, $getter)
|
||||
{
|
||||
$route = new Route(array($parameter => $value));
|
||||
$route = new Route([$parameter => $value]);
|
||||
$this->assertEquals($route->$getter(), $value);
|
||||
}
|
||||
|
||||
public function getValidParameters()
|
||||
{
|
||||
return array(
|
||||
array('value', '/Blog', 'getPath'),
|
||||
array('requirements', array('locale' => 'en'), 'getRequirements'),
|
||||
array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'),
|
||||
array('name', 'blog_index', 'getName'),
|
||||
array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'),
|
||||
array('schemes', array('https'), 'getSchemes'),
|
||||
array('methods', array('GET', 'POST'), 'getMethods'),
|
||||
array('host', '{locale}.example.com', 'getHost'),
|
||||
array('condition', 'context.getMethod() == "GET"', 'getCondition'),
|
||||
array('value', array('nl' => '/hier', 'en' => '/here'), 'getLocalizedPaths'),
|
||||
);
|
||||
return [
|
||||
['value', '/Blog', 'getPath'],
|
||||
['requirements', ['locale' => 'en'], 'getRequirements'],
|
||||
['options', ['compiler_class' => 'RouteCompiler'], 'getOptions'],
|
||||
['name', 'blog_index', 'getName'],
|
||||
['defaults', ['_controller' => 'MyBlogBundle:Blog:index'], 'getDefaults'],
|
||||
['schemes', ['https'], 'getSchemes'],
|
||||
['methods', ['GET', 'POST'], 'getMethods'],
|
||||
['host', '{locale}.example.com', 'getHost'],
|
||||
['condition', 'context.getMethod() == "GET"', 'getCondition'],
|
||||
['value', ['nl' => '/hier', 'en' => '/here'], 'getLocalizedPaths'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ class CompiledRouteTest extends TestCase
|
||||
{
|
||||
public function testAccessors()
|
||||
{
|
||||
$compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), null, array(), array(), array('variables'));
|
||||
$compiled = new CompiledRoute('prefix', 'regex', ['tokens'], [], null, [], [], ['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');
|
||||
$this->assertEquals(array('variables'), $compiled->getVariables(), '__construct() takes an array of variables as its ninth argument');
|
||||
$this->assertEquals(['tokens'], $compiled->getTokens(), '__construct() takes an array of tokens as its fourth argument');
|
||||
$this->assertEquals(['variables'], $compiled->getVariables(), '__construct() takes an array of variables as its ninth argument');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class RoutingResolverPassTest extends TestCase
|
||||
(new RoutingResolverPass())->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(array('addLoader', array(new Reference('loader1'))), array('addLoader', array(new Reference('loader2')))),
|
||||
[['addLoader', [new Reference('loader1')]], ['addLoader', [new Reference('loader2')]]],
|
||||
$container->getDefinition('routing.resolver')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,4 +13,9 @@ namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||
|
||||
abstract class AbstractClass
|
||||
{
|
||||
abstract public function abstractRouteAction();
|
||||
|
||||
public function routeAction($arg1, $arg2 = 'defaultValue2', $arg3 = 'defaultValue3')
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,12 @@ class DefaultValueController
|
||||
public function action($default = 'value')
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/hello/{name<\w+>}", name="hello_without_default")
|
||||
* @Route("/hello/{name<\w+>?Symfony}", name="hello_with_default")
|
||||
*/
|
||||
public function hello(string $name = 'World')
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ class CustomRouteCompiler extends RouteCompiler
|
||||
*/
|
||||
public static function compile(Route $route)
|
||||
{
|
||||
return new CustomCompiledRoute('', '', array(), array());
|
||||
return new CustomCompiledRoute('', '', [], []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatche
|
||||
{
|
||||
public function redirect($path, $route, $scheme = null)
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'_controller' => 'Some controller reference...',
|
||||
'path' => $path,
|
||||
'scheme' => $scheme,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml">
|
||||
<default key="_controller">FrameworkBundle:Template:template</default>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml" controller="FrameworkBundle:Template:template" />
|
||||
</routes>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml" controller="FrameworkBundle:Template:template">
|
||||
<default key="_controller">AppBundle:Blog:index</default>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://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>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="app_homepage" path="/" controller="AppBundle:Homepage:show" />
|
||||
|
||||
|
||||
@@ -15,26 +15,26 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->matchHost = true;
|
||||
$this->staticRoutes = array(
|
||||
'/test/baz' => array(array(array('_route' => 'baz'), null, null, null, false, false, null)),
|
||||
'/test/baz.html' => array(array(array('_route' => 'baz2'), null, null, null, false, false, null)),
|
||||
'/test/baz3' => array(array(array('_route' => 'baz3'), null, null, null, true, false, null)),
|
||||
'/foofoo' => array(array(array('_route' => 'foofoo', 'def' => 'test'), null, null, null, false, false, null)),
|
||||
'/spa ce' => array(array(array('_route' => 'space'), null, null, null, false, false, null)),
|
||||
'/multi/new' => array(array(array('_route' => 'overridden2'), null, null, null, false, false, null)),
|
||||
'/multi/hey' => array(array(array('_route' => 'hey'), null, null, null, true, false, null)),
|
||||
'/ababa' => array(array(array('_route' => 'ababa'), null, null, null, false, false, null)),
|
||||
'/route1' => array(array(array('_route' => 'route1'), 'a.example.com', null, null, false, false, null)),
|
||||
'/c2/route2' => array(array(array('_route' => 'route2'), 'a.example.com', null, null, false, false, null)),
|
||||
'/route4' => array(array(array('_route' => 'route4'), 'a.example.com', null, null, false, false, null)),
|
||||
'/c2/route3' => array(array(array('_route' => 'route3'), 'b.example.com', null, null, false, false, null)),
|
||||
'/route5' => array(array(array('_route' => 'route5'), 'c.example.com', null, null, false, false, null)),
|
||||
'/route6' => array(array(array('_route' => 'route6'), null, null, null, false, false, null)),
|
||||
'/route11' => array(array(array('_route' => 'route11'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
|
||||
'/route12' => array(array(array('_route' => 'route12', 'var1' => 'val'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
|
||||
'/route17' => array(array(array('_route' => 'route17'), null, null, null, false, false, null)),
|
||||
);
|
||||
$this->regexpList = array(
|
||||
$this->staticRoutes = [
|
||||
'/test/baz' => [[['_route' => 'baz'], null, null, null, false, false, null]],
|
||||
'/test/baz.html' => [[['_route' => 'baz2'], null, null, null, false, false, null]],
|
||||
'/test/baz3' => [[['_route' => 'baz3'], null, null, null, true, false, null]],
|
||||
'/foofoo' => [[['_route' => 'foofoo', 'def' => 'test'], null, null, null, false, false, null]],
|
||||
'/spa ce' => [[['_route' => 'space'], null, null, null, false, false, null]],
|
||||
'/multi/new' => [[['_route' => 'overridden2'], null, null, null, false, false, null]],
|
||||
'/multi/hey' => [[['_route' => 'hey'], null, null, null, true, false, null]],
|
||||
'/ababa' => [[['_route' => 'ababa'], null, null, null, false, false, null]],
|
||||
'/route1' => [[['_route' => 'route1'], 'a.example.com', null, null, false, false, null]],
|
||||
'/c2/route2' => [[['_route' => 'route2'], 'a.example.com', null, null, false, false, null]],
|
||||
'/route4' => [[['_route' => 'route4'], 'a.example.com', null, null, false, false, null]],
|
||||
'/c2/route3' => [[['_route' => 'route3'], 'b.example.com', null, null, false, false, null]],
|
||||
'/route5' => [[['_route' => 'route5'], 'c.example.com', null, null, false, false, null]],
|
||||
'/route6' => [[['_route' => 'route6'], null, null, null, false, false, null]],
|
||||
'/route11' => [[['_route' => 'route11'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
|
||||
'/route12' => [[['_route' => 'route12', 'var1' => 'val'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
|
||||
'/route17' => [[['_route' => 'route17'], null, null, null, false, false, null]],
|
||||
];
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|(?:(?:[^./]*+\\.)++)(?'
|
||||
.'|/foo/(baz|symfony)(*:47)'
|
||||
@@ -81,33 +81,33 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
.')'
|
||||
.')'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
47 => array(array(array('_route' => 'foo', 'def' => 'test'), array('bar'), null, null, false, true, null)),
|
||||
70 => array(array(array('_route' => 'bar'), array('foo'), array('GET' => 0, 'HEAD' => 1), null, false, true, null)),
|
||||
90 => array(array(array('_route' => 'barhead'), array('foo'), array('GET' => 0), null, false, true, null)),
|
||||
115 => array(
|
||||
array(array('_route' => 'baz4'), array('foo'), null, null, true, true, null),
|
||||
array(array('_route' => 'baz5'), array('foo'), array('POST' => 0), null, true, true, null),
|
||||
array(array('_route' => 'baz.baz6'), array('foo'), array('PUT' => 0), null, true, true, null),
|
||||
),
|
||||
131 => array(array(array('_route' => 'quoter'), array('quoter'), null, null, false, true, null)),
|
||||
160 => array(array(array('_route' => 'foo1'), array('foo'), array('PUT' => 0), null, false, true, null)),
|
||||
168 => array(array(array('_route' => 'bar1'), array('bar'), null, null, false, true, null)),
|
||||
181 => array(array(array('_route' => 'overridden'), array('var'), null, null, false, true, null)),
|
||||
204 => array(array(array('_route' => 'foo2'), array('foo1'), null, null, false, true, null)),
|
||||
212 => array(array(array('_route' => 'bar2'), array('bar1'), null, null, false, true, null)),
|
||||
248 => array(array(array('_route' => 'helloWorld', 'who' => 'World!'), array('who'), null, null, false, true, null)),
|
||||
279 => array(array(array('_route' => 'foo3'), array('_locale', 'foo'), null, null, false, true, null)),
|
||||
287 => array(array(array('_route' => 'bar3'), array('_locale', 'bar'), null, null, false, true, null)),
|
||||
309 => array(array(array('_route' => 'foo4'), array('foo'), null, null, false, true, null)),
|
||||
371 => array(array(array('_route' => 'route13'), array('var1', 'name'), null, null, false, true, null)),
|
||||
389 => array(array(array('_route' => 'route14', 'var1' => 'val'), array('var1', 'name'), null, null, false, true, null)),
|
||||
441 => array(array(array('_route' => 'route15'), array('name'), null, null, false, true, null)),
|
||||
489 => array(array(array('_route' => 'route16', 'var1' => 'val'), array('name'), null, null, false, true, null)),
|
||||
510 => array(array(array('_route' => 'a'), array(), null, null, false, false, null)),
|
||||
531 => array(array(array('_route' => 'b'), array('var'), null, null, false, true, null)),
|
||||
549 => array(array(array('_route' => 'c'), array('var'), null, null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
47 => [[['_route' => 'foo', 'def' => 'test'], ['bar'], null, null, false, true, null]],
|
||||
70 => [[['_route' => 'bar'], ['foo'], ['GET' => 0, 'HEAD' => 1], null, false, true, null]],
|
||||
90 => [[['_route' => 'barhead'], ['foo'], ['GET' => 0], null, false, true, null]],
|
||||
115 => [
|
||||
[['_route' => 'baz4'], ['foo'], null, null, true, true, null],
|
||||
[['_route' => 'baz5'], ['foo'], ['POST' => 0], null, true, true, null],
|
||||
[['_route' => 'baz.baz6'], ['foo'], ['PUT' => 0], null, true, true, null],
|
||||
],
|
||||
131 => [[['_route' => 'quoter'], ['quoter'], null, null, false, true, null]],
|
||||
160 => [[['_route' => 'foo1'], ['foo'], ['PUT' => 0], null, false, true, null]],
|
||||
168 => [[['_route' => 'bar1'], ['bar'], null, null, false, true, null]],
|
||||
181 => [[['_route' => 'overridden'], ['var'], null, null, false, true, null]],
|
||||
204 => [[['_route' => 'foo2'], ['foo1'], null, null, false, true, null]],
|
||||
212 => [[['_route' => 'bar2'], ['bar1'], null, null, false, true, null]],
|
||||
248 => [[['_route' => 'helloWorld', 'who' => 'World!'], ['who'], null, null, false, true, null]],
|
||||
279 => [[['_route' => 'foo3'], ['_locale', 'foo'], null, null, false, true, null]],
|
||||
287 => [[['_route' => 'bar3'], ['_locale', 'bar'], null, null, false, true, null]],
|
||||
309 => [[['_route' => 'foo4'], ['foo'], null, null, false, true, null]],
|
||||
371 => [[['_route' => 'route13'], ['var1', 'name'], null, null, false, true, null]],
|
||||
389 => [[['_route' => 'route14', 'var1' => 'val'], ['var1', 'name'], null, null, false, true, null]],
|
||||
441 => [[['_route' => 'route15'], ['name'], null, null, false, true, null]],
|
||||
489 => [[['_route' => 'route16', 'var1' => 'val'], ['name'], null, null, false, true, null]],
|
||||
510 => [[['_route' => 'a'], [], null, null, false, false, null]],
|
||||
531 => [[['_route' => 'b'], ['var'], null, null, false, true, null]],
|
||||
549 => [[['_route' => 'c'], ['var'], null, null, false, true, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->regexpList = array(
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|/(en|fr)/(?'
|
||||
.'|admin/post(?'
|
||||
@@ -45,22 +45,22 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
.')'
|
||||
.'|/(en|fr)?(*:264)'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
32 => array(array(array('_route' => 'a', '_locale' => 'en'), array('_locale'), null, null, true, false, null)),
|
||||
46 => array(array(array('_route' => 'b', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
|
||||
58 => array(array(array('_route' => 'c', '_locale' => 'en'), array('_locale', 'id'), null, null, false, true, null)),
|
||||
75 => array(array(array('_route' => 'd', '_locale' => 'en'), array('_locale', 'id'), null, null, false, false, null)),
|
||||
94 => array(array(array('_route' => 'e', '_locale' => 'en'), array('_locale', 'id'), null, null, false, false, null)),
|
||||
110 => array(array(array('_route' => 'f', '_locale' => 'en'), array('_locale'), null, null, true, false, null)),
|
||||
130 => array(array(array('_route' => 'g', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
|
||||
154 => array(array(array('_route' => 'h', '_locale' => 'en'), array('_locale', 'page'), null, null, false, true, null)),
|
||||
175 => array(array(array('_route' => 'i', '_locale' => 'en'), array('_locale', 'page'), null, null, false, true, null)),
|
||||
202 => array(array(array('_route' => 'j', '_locale' => 'en'), array('_locale', 'id'), null, null, false, false, null)),
|
||||
216 => array(array(array('_route' => 'k', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
|
||||
234 => array(array(array('_route' => 'l', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
|
||||
245 => array(array(array('_route' => 'm', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
|
||||
264 => array(array(array('_route' => 'n', '_locale' => 'en'), array('_locale'), null, null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
32 => [[['_route' => 'a', '_locale' => 'en'], ['_locale'], null, null, true, false, null]],
|
||||
46 => [[['_route' => 'b', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
|
||||
58 => [[['_route' => 'c', '_locale' => 'en'], ['_locale', 'id'], null, null, false, true, null]],
|
||||
75 => [[['_route' => 'd', '_locale' => 'en'], ['_locale', 'id'], null, null, false, false, null]],
|
||||
94 => [[['_route' => 'e', '_locale' => 'en'], ['_locale', 'id'], null, null, false, false, null]],
|
||||
110 => [[['_route' => 'f', '_locale' => 'en'], ['_locale'], null, null, true, false, null]],
|
||||
130 => [[['_route' => 'g', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
|
||||
154 => [[['_route' => 'h', '_locale' => 'en'], ['_locale', 'page'], null, null, false, true, null]],
|
||||
175 => [[['_route' => 'i', '_locale' => 'en'], ['_locale', 'page'], null, null, false, true, null]],
|
||||
202 => [[['_route' => 'j', '_locale' => 'en'], ['_locale', 'id'], null, null, false, false, null]],
|
||||
216 => [[['_route' => 'k', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
|
||||
234 => [[['_route' => 'l', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
|
||||
245 => [[['_route' => 'm', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
|
||||
264 => [[['_route' => 'n', '_locale' => 'en'], ['_locale'], null, null, false, true, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->regexpList = array(
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|/abc([^/]++)/(?'
|
||||
.'|1(?'
|
||||
@@ -33,14 +33,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
.')'
|
||||
.')'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
27 => array(array(array('_route' => 'r1'), array('foo'), null, null, false, false, null)),
|
||||
38 => array(array(array('_route' => 'r10'), array('foo'), null, null, false, false, null)),
|
||||
46 => array(array(array('_route' => 'r100'), array('foo'), null, null, false, false, null)),
|
||||
59 => array(array(array('_route' => 'r2'), array('foo'), null, null, false, false, null)),
|
||||
70 => array(array(array('_route' => 'r20'), array('foo'), null, null, false, false, null)),
|
||||
78 => array(array(array('_route' => 'r200'), array('foo'), null, null, false, false, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
27 => [[['_route' => 'r1'], ['foo'], null, null, false, false, null]],
|
||||
38 => [[['_route' => 'r10'], ['foo'], null, null, false, false, null]],
|
||||
46 => [[['_route' => 'r100'], ['foo'], null, null, false, false, null]],
|
||||
59 => [[['_route' => 'r2'], ['foo'], null, null, false, false, null]],
|
||||
70 => [[['_route' => 'r20'], ['foo'], null, null, false, false, null]],
|
||||
78 => [[['_route' => 'r200'], ['foo'], null, null, false, false, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->matchHost = true;
|
||||
$this->regexpList = array(
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|(?i:([^\\.]++)\\.exampple\\.com)\\.(?'
|
||||
.'|/abc([^/]++)(?'
|
||||
@@ -23,12 +23,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
.')'
|
||||
.')'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
56 => array(
|
||||
array(array('_route' => 'r1'), array('foo', 'foo'), null, null, false, true, null),
|
||||
array(array('_route' => 'r2'), array('foo', 'foo'), null, null, false, true, null),
|
||||
),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
56 => [
|
||||
[['_route' => 'r1'], ['foo', 'foo'], null, null, false, true, null],
|
||||
[['_route' => 'r2'], ['foo', 'foo'], null, null, false, true, null],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,28 +15,28 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->matchHost = true;
|
||||
$this->staticRoutes = array(
|
||||
'/test/baz' => array(array(array('_route' => 'baz'), null, null, null, false, false, null)),
|
||||
'/test/baz.html' => array(array(array('_route' => 'baz2'), null, null, null, false, false, null)),
|
||||
'/test/baz3' => array(array(array('_route' => 'baz3'), null, null, null, true, false, null)),
|
||||
'/foofoo' => array(array(array('_route' => 'foofoo', 'def' => 'test'), null, null, null, false, false, null)),
|
||||
'/spa ce' => array(array(array('_route' => 'space'), null, null, null, false, false, null)),
|
||||
'/multi/new' => array(array(array('_route' => 'overridden2'), null, null, null, false, false, null)),
|
||||
'/multi/hey' => array(array(array('_route' => 'hey'), null, null, null, true, false, null)),
|
||||
'/ababa' => array(array(array('_route' => 'ababa'), null, null, null, false, false, null)),
|
||||
'/route1' => array(array(array('_route' => 'route1'), 'a.example.com', null, null, false, false, null)),
|
||||
'/c2/route2' => array(array(array('_route' => 'route2'), 'a.example.com', null, null, false, false, null)),
|
||||
'/route4' => array(array(array('_route' => 'route4'), 'a.example.com', null, null, false, false, null)),
|
||||
'/c2/route3' => array(array(array('_route' => 'route3'), 'b.example.com', null, null, false, false, null)),
|
||||
'/route5' => array(array(array('_route' => 'route5'), 'c.example.com', null, null, false, false, null)),
|
||||
'/route6' => array(array(array('_route' => 'route6'), null, null, null, false, false, null)),
|
||||
'/route11' => array(array(array('_route' => 'route11'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
|
||||
'/route12' => array(array(array('_route' => 'route12', 'var1' => 'val'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
|
||||
'/route17' => array(array(array('_route' => 'route17'), null, null, null, false, false, null)),
|
||||
'/secure' => array(array(array('_route' => 'secure'), null, null, array('https' => 0), false, false, null)),
|
||||
'/nonsecure' => array(array(array('_route' => 'nonsecure'), null, null, array('http' => 0), false, false, null)),
|
||||
);
|
||||
$this->regexpList = array(
|
||||
$this->staticRoutes = [
|
||||
'/test/baz' => [[['_route' => 'baz'], null, null, null, false, false, null]],
|
||||
'/test/baz.html' => [[['_route' => 'baz2'], null, null, null, false, false, null]],
|
||||
'/test/baz3' => [[['_route' => 'baz3'], null, null, null, true, false, null]],
|
||||
'/foofoo' => [[['_route' => 'foofoo', 'def' => 'test'], null, null, null, false, false, null]],
|
||||
'/spa ce' => [[['_route' => 'space'], null, null, null, false, false, null]],
|
||||
'/multi/new' => [[['_route' => 'overridden2'], null, null, null, false, false, null]],
|
||||
'/multi/hey' => [[['_route' => 'hey'], null, null, null, true, false, null]],
|
||||
'/ababa' => [[['_route' => 'ababa'], null, null, null, false, false, null]],
|
||||
'/route1' => [[['_route' => 'route1'], 'a.example.com', null, null, false, false, null]],
|
||||
'/c2/route2' => [[['_route' => 'route2'], 'a.example.com', null, null, false, false, null]],
|
||||
'/route4' => [[['_route' => 'route4'], 'a.example.com', null, null, false, false, null]],
|
||||
'/c2/route3' => [[['_route' => 'route3'], 'b.example.com', null, null, false, false, null]],
|
||||
'/route5' => [[['_route' => 'route5'], 'c.example.com', null, null, false, false, null]],
|
||||
'/route6' => [[['_route' => 'route6'], null, null, null, false, false, null]],
|
||||
'/route11' => [[['_route' => 'route11'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
|
||||
'/route12' => [[['_route' => 'route12', 'var1' => 'val'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
|
||||
'/route17' => [[['_route' => 'route17'], null, null, null, false, false, null]],
|
||||
'/secure' => [[['_route' => 'secure'], null, null, ['https' => 0], false, false, null]],
|
||||
'/nonsecure' => [[['_route' => 'nonsecure'], null, null, ['http' => 0], false, false, null]],
|
||||
];
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|(?:(?:[^./]*+\\.)++)(?'
|
||||
.'|/foo/(baz|symfony)(*:47)'
|
||||
@@ -83,33 +83,33 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
.')'
|
||||
.')'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
47 => array(array(array('_route' => 'foo', 'def' => 'test'), array('bar'), null, null, false, true, null)),
|
||||
70 => array(array(array('_route' => 'bar'), array('foo'), array('GET' => 0, 'HEAD' => 1), null, false, true, null)),
|
||||
90 => array(array(array('_route' => 'barhead'), array('foo'), array('GET' => 0), null, false, true, null)),
|
||||
115 => array(
|
||||
array(array('_route' => 'baz4'), array('foo'), null, null, true, true, null),
|
||||
array(array('_route' => 'baz5'), array('foo'), array('POST' => 0), null, true, true, null),
|
||||
array(array('_route' => 'baz.baz6'), array('foo'), array('PUT' => 0), null, true, true, null),
|
||||
),
|
||||
131 => array(array(array('_route' => 'quoter'), array('quoter'), null, null, false, true, null)),
|
||||
160 => array(array(array('_route' => 'foo1'), array('foo'), array('PUT' => 0), null, false, true, null)),
|
||||
168 => array(array(array('_route' => 'bar1'), array('bar'), null, null, false, true, null)),
|
||||
181 => array(array(array('_route' => 'overridden'), array('var'), null, null, false, true, null)),
|
||||
204 => array(array(array('_route' => 'foo2'), array('foo1'), null, null, false, true, null)),
|
||||
212 => array(array(array('_route' => 'bar2'), array('bar1'), null, null, false, true, null)),
|
||||
248 => array(array(array('_route' => 'helloWorld', 'who' => 'World!'), array('who'), null, null, false, true, null)),
|
||||
279 => array(array(array('_route' => 'foo3'), array('_locale', 'foo'), null, null, false, true, null)),
|
||||
287 => array(array(array('_route' => 'bar3'), array('_locale', 'bar'), null, null, false, true, null)),
|
||||
309 => array(array(array('_route' => 'foo4'), array('foo'), null, null, false, true, null)),
|
||||
371 => array(array(array('_route' => 'route13'), array('var1', 'name'), null, null, false, true, null)),
|
||||
389 => array(array(array('_route' => 'route14', 'var1' => 'val'), array('var1', 'name'), null, null, false, true, null)),
|
||||
441 => array(array(array('_route' => 'route15'), array('name'), null, null, false, true, null)),
|
||||
489 => array(array(array('_route' => 'route16', 'var1' => 'val'), array('name'), null, null, false, true, null)),
|
||||
510 => array(array(array('_route' => 'a'), array(), null, null, false, false, null)),
|
||||
531 => array(array(array('_route' => 'b'), array('var'), null, null, false, true, null)),
|
||||
549 => array(array(array('_route' => 'c'), array('var'), null, null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
47 => [[['_route' => 'foo', 'def' => 'test'], ['bar'], null, null, false, true, null]],
|
||||
70 => [[['_route' => 'bar'], ['foo'], ['GET' => 0, 'HEAD' => 1], null, false, true, null]],
|
||||
90 => [[['_route' => 'barhead'], ['foo'], ['GET' => 0], null, false, true, null]],
|
||||
115 => [
|
||||
[['_route' => 'baz4'], ['foo'], null, null, true, true, null],
|
||||
[['_route' => 'baz5'], ['foo'], ['POST' => 0], null, true, true, null],
|
||||
[['_route' => 'baz.baz6'], ['foo'], ['PUT' => 0], null, true, true, null],
|
||||
],
|
||||
131 => [[['_route' => 'quoter'], ['quoter'], null, null, false, true, null]],
|
||||
160 => [[['_route' => 'foo1'], ['foo'], ['PUT' => 0], null, false, true, null]],
|
||||
168 => [[['_route' => 'bar1'], ['bar'], null, null, false, true, null]],
|
||||
181 => [[['_route' => 'overridden'], ['var'], null, null, false, true, null]],
|
||||
204 => [[['_route' => 'foo2'], ['foo1'], null, null, false, true, null]],
|
||||
212 => [[['_route' => 'bar2'], ['bar1'], null, null, false, true, null]],
|
||||
248 => [[['_route' => 'helloWorld', 'who' => 'World!'], ['who'], null, null, false, true, null]],
|
||||
279 => [[['_route' => 'foo3'], ['_locale', 'foo'], null, null, false, true, null]],
|
||||
287 => [[['_route' => 'bar3'], ['_locale', 'bar'], null, null, false, true, null]],
|
||||
309 => [[['_route' => 'foo4'], ['foo'], null, null, false, true, null]],
|
||||
371 => [[['_route' => 'route13'], ['var1', 'name'], null, null, false, true, null]],
|
||||
389 => [[['_route' => 'route14', 'var1' => 'val'], ['var1', 'name'], null, null, false, true, null]],
|
||||
441 => [[['_route' => 'route15'], ['name'], null, null, false, true, null]],
|
||||
489 => [[['_route' => 'route16', 'var1' => 'val'], ['name'], null, null, false, true, null]],
|
||||
510 => [[['_route' => 'a'], [], null, null, false, false, null]],
|
||||
531 => [[['_route' => 'b'], ['var'], null, null, false, true, null]],
|
||||
549 => [[['_route' => 'c'], ['var'], null, null, false, true, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,18 +14,18 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->staticRoutes = array(
|
||||
'/rootprefix/test' => array(array(array('_route' => 'static'), null, null, null, false, false, null)),
|
||||
'/with-condition' => array(array(array('_route' => 'with-condition'), null, null, null, false, false, -1)),
|
||||
);
|
||||
$this->regexpList = array(
|
||||
$this->staticRoutes = [
|
||||
'/rootprefix/test' => [[['_route' => 'static'], null, null, null, false, false, null]],
|
||||
'/with-condition' => [[['_route' => 'with-condition'], null, null, null, false, false, -1]],
|
||||
];
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|/rootprefix/([^/]++)(*:27)'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
27 => array(array(array('_route' => 'dynamic'), array('var'), null, null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
27 => [[['_route' => 'dynamic'], ['var'], null, null, false, true, null]],
|
||||
];
|
||||
$this->checkCondition = static function ($condition, $context, $request) {
|
||||
switch ($condition) {
|
||||
case -1: return ($context->getMethod() == "GET");
|
||||
|
||||
@@ -14,15 +14,15 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->staticRoutes = array(
|
||||
'/just_head' => array(array(array('_route' => 'just_head'), null, array('HEAD' => 0), null, false, false, null)),
|
||||
'/head_and_get' => array(array(array('_route' => 'head_and_get'), null, array('HEAD' => 0, 'GET' => 1), null, false, false, null)),
|
||||
'/get_and_head' => array(array(array('_route' => 'get_and_head'), null, array('GET' => 0, 'HEAD' => 1), null, false, false, null)),
|
||||
'/post_and_head' => array(array(array('_route' => 'post_and_head'), null, array('POST' => 0, 'HEAD' => 1), null, false, false, null)),
|
||||
'/put_and_post' => array(
|
||||
array(array('_route' => 'put_and_post'), null, array('PUT' => 0, 'POST' => 1), null, false, false, null),
|
||||
array(array('_route' => 'put_and_get_and_head'), null, array('PUT' => 0, 'GET' => 1, 'HEAD' => 2), null, false, false, null),
|
||||
),
|
||||
);
|
||||
$this->staticRoutes = [
|
||||
'/just_head' => [[['_route' => 'just_head'], null, ['HEAD' => 0], null, false, false, null]],
|
||||
'/head_and_get' => [[['_route' => 'head_and_get'], null, ['HEAD' => 0, 'GET' => 1], null, false, false, null]],
|
||||
'/get_and_head' => [[['_route' => 'get_and_head'], null, ['GET' => 0, 'HEAD' => 1], null, false, false, null]],
|
||||
'/post_and_head' => [[['_route' => 'post_and_head'], null, ['POST' => 0, 'HEAD' => 1], null, false, false, null]],
|
||||
'/put_and_post' => [
|
||||
[['_route' => 'put_and_post'], null, ['PUT' => 0, 'POST' => 1], null, false, false, null],
|
||||
[['_route' => 'put_and_get_and_head'], null, ['PUT' => 0, 'GET' => 1, 'HEAD' => 2], null, false, false, null],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,29 +14,29 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->staticRoutes = array(
|
||||
'/a/11' => array(array(array('_route' => 'a_first'), null, null, null, false, false, null)),
|
||||
'/a/22' => array(array(array('_route' => 'a_second'), null, null, null, false, false, null)),
|
||||
'/a/333' => array(array(array('_route' => 'a_third'), null, null, null, false, false, null)),
|
||||
'/a/44' => array(array(array('_route' => 'a_fourth'), null, null, null, true, false, null)),
|
||||
'/a/55' => array(array(array('_route' => 'a_fifth'), null, null, null, true, false, null)),
|
||||
'/a/66' => array(array(array('_route' => 'a_sixth'), null, null, null, true, false, null)),
|
||||
'/nested/group/a' => array(array(array('_route' => 'nested_a'), null, null, null, true, false, null)),
|
||||
'/nested/group/b' => array(array(array('_route' => 'nested_b'), null, null, null, true, false, null)),
|
||||
'/nested/group/c' => array(array(array('_route' => 'nested_c'), null, null, null, true, false, null)),
|
||||
'/slashed/group' => array(array(array('_route' => 'slashed_a'), null, null, null, true, false, null)),
|
||||
'/slashed/group/b' => array(array(array('_route' => 'slashed_b'), null, null, null, true, false, null)),
|
||||
'/slashed/group/c' => array(array(array('_route' => 'slashed_c'), null, null, null, true, false, null)),
|
||||
);
|
||||
$this->regexpList = array(
|
||||
$this->staticRoutes = [
|
||||
'/a/11' => [[['_route' => 'a_first'], null, null, null, false, false, null]],
|
||||
'/a/22' => [[['_route' => 'a_second'], null, null, null, false, false, null]],
|
||||
'/a/333' => [[['_route' => 'a_third'], null, null, null, false, false, null]],
|
||||
'/a/44' => [[['_route' => 'a_fourth'], null, null, null, true, false, null]],
|
||||
'/a/55' => [[['_route' => 'a_fifth'], null, null, null, true, false, null]],
|
||||
'/a/66' => [[['_route' => 'a_sixth'], null, null, null, true, false, null]],
|
||||
'/nested/group/a' => [[['_route' => 'nested_a'], null, null, null, true, false, null]],
|
||||
'/nested/group/b' => [[['_route' => 'nested_b'], null, null, null, true, false, null]],
|
||||
'/nested/group/c' => [[['_route' => 'nested_c'], null, null, null, true, false, null]],
|
||||
'/slashed/group' => [[['_route' => 'slashed_a'], null, null, null, true, false, null]],
|
||||
'/slashed/group/b' => [[['_route' => 'slashed_b'], null, null, null, true, false, null]],
|
||||
'/slashed/group/c' => [[['_route' => 'slashed_c'], null, null, null, true, false, null]],
|
||||
];
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|/([^/]++)(*:16)'
|
||||
.'|/nested/([^/]++)(*:39)'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
16 => array(array(array('_route' => 'a_wildcard'), array('param'), null, null, false, true, null)),
|
||||
39 => array(array(array('_route' => 'nested_wildcard'), array('param'), null, null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
16 => [[['_route' => 'a_wildcard'], ['param'], null, null, false, true, null]],
|
||||
39 => [[['_route' => 'nested_wildcard'], ['param'], null, null, false, true, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,17 +14,17 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->staticRoutes = array(
|
||||
'/trailing/simple/no-methods' => array(array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null, true, false, null)),
|
||||
'/trailing/simple/get-method' => array(array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null, true, false, null)),
|
||||
'/trailing/simple/head-method' => array(array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, true, false, null)),
|
||||
'/trailing/simple/post-method' => array(array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null, true, false, null)),
|
||||
'/not-trailing/simple/no-methods' => array(array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null, false, false, null)),
|
||||
'/not-trailing/simple/get-method' => array(array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null, false, false, null)),
|
||||
'/not-trailing/simple/head-method' => array(array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, false, false, null)),
|
||||
'/not-trailing/simple/post-method' => array(array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null, false, false, null)),
|
||||
);
|
||||
$this->regexpList = array(
|
||||
$this->staticRoutes = [
|
||||
'/trailing/simple/no-methods' => [[['_route' => 'simple_trailing_slash_no_methods'], null, null, null, true, false, null]],
|
||||
'/trailing/simple/get-method' => [[['_route' => 'simple_trailing_slash_GET_method'], null, ['GET' => 0], null, true, false, null]],
|
||||
'/trailing/simple/head-method' => [[['_route' => 'simple_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, true, false, null]],
|
||||
'/trailing/simple/post-method' => [[['_route' => 'simple_trailing_slash_POST_method'], null, ['POST' => 0], null, true, false, null]],
|
||||
'/not-trailing/simple/no-methods' => [[['_route' => 'simple_not_trailing_slash_no_methods'], null, null, null, false, false, null]],
|
||||
'/not-trailing/simple/get-method' => [[['_route' => 'simple_not_trailing_slash_GET_method'], null, ['GET' => 0], null, false, false, null]],
|
||||
'/not-trailing/simple/head-method' => [[['_route' => 'simple_not_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, false, false, null]],
|
||||
'/not-trailing/simple/post-method' => [[['_route' => 'simple_not_trailing_slash_POST_method'], null, ['POST' => 0], null, false, false, null]],
|
||||
];
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|/trailing/regex/(?'
|
||||
.'|no\\-methods/([^/]++)(*:46)'
|
||||
@@ -39,16 +39,16 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
.'|post\\-method/([^/]++)(*:269)'
|
||||
.')'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
46 => array(array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null, true, true, null)),
|
||||
73 => array(array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, true, true, null)),
|
||||
101 => array(array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, true, true, null)),
|
||||
130 => array(array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, true, true, null)),
|
||||
183 => array(array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null, false, true, null)),
|
||||
211 => array(array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, false, true, null)),
|
||||
240 => array(array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, false, true, null)),
|
||||
269 => array(array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
46 => [[['_route' => 'regex_trailing_slash_no_methods'], ['param'], null, null, true, true, null]],
|
||||
73 => [[['_route' => 'regex_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, true, true, null]],
|
||||
101 => [[['_route' => 'regex_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, true, true, null]],
|
||||
130 => [[['_route' => 'regex_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, true, true, null]],
|
||||
183 => [[['_route' => 'regex_not_trailing_slash_no_methods'], ['param'], null, null, false, true, null]],
|
||||
211 => [[['_route' => 'regex_not_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, false, true, null]],
|
||||
240 => [[['_route' => 'regex_not_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, false, true, null]],
|
||||
269 => [[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,17 +14,17 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->staticRoutes = array(
|
||||
'/trailing/simple/no-methods' => array(array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null, true, false, null)),
|
||||
'/trailing/simple/get-method' => array(array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null, true, false, null)),
|
||||
'/trailing/simple/head-method' => array(array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, true, false, null)),
|
||||
'/trailing/simple/post-method' => array(array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null, true, false, null)),
|
||||
'/not-trailing/simple/no-methods' => array(array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null, false, false, null)),
|
||||
'/not-trailing/simple/get-method' => array(array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null, false, false, null)),
|
||||
'/not-trailing/simple/head-method' => array(array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, false, false, null)),
|
||||
'/not-trailing/simple/post-method' => array(array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null, false, false, null)),
|
||||
);
|
||||
$this->regexpList = array(
|
||||
$this->staticRoutes = [
|
||||
'/trailing/simple/no-methods' => [[['_route' => 'simple_trailing_slash_no_methods'], null, null, null, true, false, null]],
|
||||
'/trailing/simple/get-method' => [[['_route' => 'simple_trailing_slash_GET_method'], null, ['GET' => 0], null, true, false, null]],
|
||||
'/trailing/simple/head-method' => [[['_route' => 'simple_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, true, false, null]],
|
||||
'/trailing/simple/post-method' => [[['_route' => 'simple_trailing_slash_POST_method'], null, ['POST' => 0], null, true, false, null]],
|
||||
'/not-trailing/simple/no-methods' => [[['_route' => 'simple_not_trailing_slash_no_methods'], null, null, null, false, false, null]],
|
||||
'/not-trailing/simple/get-method' => [[['_route' => 'simple_not_trailing_slash_GET_method'], null, ['GET' => 0], null, false, false, null]],
|
||||
'/not-trailing/simple/head-method' => [[['_route' => 'simple_not_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, false, false, null]],
|
||||
'/not-trailing/simple/post-method' => [[['_route' => 'simple_not_trailing_slash_POST_method'], null, ['POST' => 0], null, false, false, null]],
|
||||
];
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|/trailing/regex/(?'
|
||||
.'|no\\-methods/([^/]++)(*:46)'
|
||||
@@ -39,16 +39,16 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
.'|post\\-method/([^/]++)(*:269)'
|
||||
.')'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
46 => array(array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null, true, true, null)),
|
||||
73 => array(array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, true, true, null)),
|
||||
101 => array(array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, true, true, null)),
|
||||
130 => array(array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, true, true, null)),
|
||||
183 => array(array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null, false, true, null)),
|
||||
211 => array(array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, false, true, null)),
|
||||
240 => array(array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, false, true, null)),
|
||||
269 => array(array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
46 => [[['_route' => 'regex_trailing_slash_no_methods'], ['param'], null, null, true, true, null]],
|
||||
73 => [[['_route' => 'regex_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, true, true, null]],
|
||||
101 => [[['_route' => 'regex_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, true, true, null]],
|
||||
130 => [[['_route' => 'regex_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, true, true, null]],
|
||||
183 => [[['_route' => 'regex_not_trailing_slash_no_methods'], ['param'], null, null, false, true, null]],
|
||||
211 => [[['_route' => 'regex_not_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, false, true, null]],
|
||||
240 => [[['_route' => 'regex_not_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, false, true, null]],
|
||||
269 => [[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->regexpList = array(
|
||||
$this->regexpList = [
|
||||
0 => '{^(?'
|
||||
.'|/(a)(*:11)'
|
||||
.')/?$}sD',
|
||||
@@ -24,11 +24,11 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
22 => '{^(?'
|
||||
.'|/(.)(*:33)'
|
||||
.')/?$}sD',
|
||||
);
|
||||
$this->dynamicRoutes = array(
|
||||
11 => array(array(array('_route' => 'a'), array('a'), null, null, false, true, null)),
|
||||
22 => array(array(array('_route' => 'b'), array('a'), null, null, false, true, null)),
|
||||
33 => array(array(array('_route' => 'c'), array('a'), null, null, false, true, null)),
|
||||
);
|
||||
];
|
||||
$this->dynamicRoutes = [
|
||||
11 => [[['_route' => 'a'], ['a'], null, null, false, true, null]],
|
||||
22 => [[['_route' => 'b'], ['a'], null, null, false, true, null]],
|
||||
33 => [[['_route' => 'c'], ['a'], null, null, false, true, null]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->matchHost = true;
|
||||
$this->staticRoutes = array(
|
||||
'/' => array(
|
||||
array(array('_route' => 'a'), '#^(?P<d>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null),
|
||||
array(array('_route' => 'c'), '#^(?P<e>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null),
|
||||
array(array('_route' => 'b'), 'd.c.b.a', null, null, false, false, null),
|
||||
),
|
||||
);
|
||||
$this->staticRoutes = [
|
||||
'/' => [
|
||||
[['_route' => 'a'], '#^(?P<d>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null],
|
||||
[['_route' => 'c'], '#^(?P<e>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null],
|
||||
[['_route' => 'b'], 'd.c.b.a', null, null, false, false, null],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="bar_route" path="/bar" controller="AppBundle:Bar:view" />
|
||||
</routes>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="baz_route" path="/baz" controller="AppBundle:Baz:view" />
|
||||
</routes>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="ba?.xml" />
|
||||
</routes>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="b?r.xml" />
|
||||
</routes>
|
||||
|
||||
@@ -6,7 +6,7 @@ return function (RoutingConfigurator $routes) {
|
||||
$collection = $routes->collection();
|
||||
|
||||
$collection->add('bar_route', '/bar')
|
||||
->defaults(array('_controller' => 'AppBundle:Bar:view'));
|
||||
->defaults(['_controller' => 'AppBundle:Bar:view']);
|
||||
|
||||
return $collection;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ return function (RoutingConfigurator $routes) {
|
||||
$collection = $routes->collection();
|
||||
|
||||
$collection->add('baz_route', '/baz')
|
||||
->defaults(array('_controller' => 'AppBundle:Baz:view'));
|
||||
->defaults(['_controller' => 'AppBundle:Baz:view']);
|
||||
|
||||
return $collection;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="../controller/routing.xml" />
|
||||
<import resource="../controller/routing.xml" prefix="/api" name-prefix="api_" />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="../controller/routing.xml" prefix="/slash" name-prefix="a_" />
|
||||
<import resource="../controller/routing.xml" prefix="/no-slash" name-prefix="b_" trailing-slash-on-root="false" />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="localized">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
<route id="imported" path="/suffix">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
</route>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
<route id="imported">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
<path locale="en">/suffix</path>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
<import resource="./imported-with-locale-but-not-localized.xml">
|
||||
<prefix locale="fr">/le-prefix</prefix>
|
||||
<prefix locale="en">/the-prefix</prefix>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
<import resource="./imported-with-locale.xml">
|
||||
<prefix locale="fr">/le-prefix</prefix>
|
||||
<prefix locale="en">/the-prefix</prefix>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route path="/test"></route>
|
||||
</routes>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="myroute"></route>
|
||||
</routes>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<r:routes xmlns:r="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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<r:route id="blog_show" path="/blog/{slug}" host="{_locale}.example.com">
|
||||
<r:default key="_controller">MyBundle:Blog:show</r:default>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<foo>bar</foo>
|
||||
</routes>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}">
|
||||
<default key="foo" xsi:nil="true" />
|
||||
|
||||
@@ -7,13 +7,13 @@ return function (RoutingConfigurator $routes) {
|
||||
->collection()
|
||||
->add('foo', '/foo')
|
||||
->condition('abc')
|
||||
->options(array('utf8' => true))
|
||||
->options(['utf8' => true])
|
||||
->add('buz', 'zub')
|
||||
->controller('foo:act');
|
||||
|
||||
$routes->import('php_dsl_sub.php')
|
||||
->prefix('/sub')
|
||||
->requirements(array('id' => '\d+'));
|
||||
->requirements(['id' => '\d+']);
|
||||
|
||||
$routes->import('php_dsl_sub.php')
|
||||
->namePrefix('z_')
|
||||
@@ -23,7 +23,7 @@ return function (RoutingConfigurator $routes) {
|
||||
->prefix('/bus', false);
|
||||
|
||||
$routes->add('ouf', '/ouf')
|
||||
->schemes(array('https'))
|
||||
->methods(array('GET'))
|
||||
->defaults(array('id' => 0));
|
||||
->schemes(['https'])
|
||||
->methods(['GET'])
|
||||
->defaults(['id' => 0]);
|
||||
};
|
||||
|
||||
@@ -5,13 +5,13 @@ namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$routes
|
||||
->collection()
|
||||
->prefix(array('en' => '/glish'))
|
||||
->prefix(['en' => '/glish'])
|
||||
->add('foo', '/foo')
|
||||
->add('bar', array('en' => '/bar'));
|
||||
->add('bar', ['en' => '/bar']);
|
||||
|
||||
$routes
|
||||
->add('baz', array('en' => '/baz'));
|
||||
->add('baz', ['en' => '/baz']);
|
||||
|
||||
$routes->import('php_dsl_sub_i18n.php')
|
||||
->prefix(array('fr' => '/ench'));
|
||||
->prefix(['fr' => '/ench']);
|
||||
};
|
||||
|
||||
@@ -6,6 +6,6 @@ return function (RoutingConfigurator $routes) {
|
||||
$add = $routes->collection('c_')
|
||||
->prefix('pub');
|
||||
|
||||
$add('foo', array('fr' => '/foo'));
|
||||
$add('bar', array('fr' => '/bar'));
|
||||
$add('foo', ['fr' => '/foo']);
|
||||
$add('bar', ['fr' => '/bar']);
|
||||
};
|
||||
|
||||
@@ -9,13 +9,13 @@ return new class() {
|
||||
->collection()
|
||||
->add('foo', '/foo')
|
||||
->condition('abc')
|
||||
->options(array('utf8' => true))
|
||||
->options(['utf8' => true])
|
||||
->add('buz', 'zub')
|
||||
->controller('foo:act');
|
||||
|
||||
$routes->import('php_dsl_sub.php')
|
||||
->prefix('/sub')
|
||||
->requirements(array('id' => '\d+'));
|
||||
->requirements(['id' => '\d+']);
|
||||
|
||||
$routes->import('php_dsl_sub.php')
|
||||
->namePrefix('z_')
|
||||
@@ -25,8 +25,8 @@ return new class() {
|
||||
->prefix('/bus', false);
|
||||
|
||||
$routes->add('ouf', '/ouf')
|
||||
->schemes(array('https'))
|
||||
->methods(array('GET'))
|
||||
->defaults(array('id' => 0));
|
||||
->schemes(['https'])
|
||||
->methods(['GET'])
|
||||
->defaults(['id' => 0]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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">
|
||||
https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
|
||||
@@ -6,12 +6,12 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('blog_show', new Route(
|
||||
'/blog/{slug}',
|
||||
array('_controller' => 'MyBlogBundle:Blog:show'),
|
||||
array('locale' => '\w+'),
|
||||
array('compiler_class' => 'RouteCompiler'),
|
||||
['_controller' => 'MyBlogBundle:Blog:show'],
|
||||
['locale' => '\w+'],
|
||||
['compiler_class' => 'RouteCompiler'],
|
||||
'{locale}.example.com',
|
||||
array('https'),
|
||||
array('GET', 'POST', 'put', 'OpTiOnS'),
|
||||
['https'],
|
||||
['GET', 'POST', 'put', 'OpTiOnS'],
|
||||
'context.getMethod() == "GET"'
|
||||
));
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}" host="{locale}.example.com" methods="GET|POST put,OpTiOnS" schemes="hTTps">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
/** @var $loader \Symfony\Component\Routing\Loader\PhpFileLoader */
|
||||
/** @var \Symfony\Component\Routing\RouteCollection $collection */
|
||||
$collection = $loader->import('validpattern.php');
|
||||
$collection->addDefaults(array(
|
||||
$collection->addDefaults([
|
||||
'foo' => 123,
|
||||
));
|
||||
$collection->addRequirements(array(
|
||||
]);
|
||||
$collection->addRequirements([
|
||||
'foo' => '\d+',
|
||||
));
|
||||
$collection->addOptions(array(
|
||||
]);
|
||||
$collection->addOptions([
|
||||
'foo' => 'bar',
|
||||
));
|
||||
]);
|
||||
$collection->setCondition('context.getMethod() == "POST"');
|
||||
$collection->addPrefix('/prefix');
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<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">
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="validpattern.xml" prefix="/{foo}" host="">
|
||||
<default key="foo">123</default>
|
||||
|
||||
@@ -73,10 +73,10 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
|
||||
$projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
|
||||
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
|
||||
@@ -90,9 +90,9 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
$this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test'));
|
||||
$this->routeCollection->add('test.nl', (new Route('/testen/is/leuk'))->setDefault('_locale', 'nl')->setDefault('_canonical_route', 'test'));
|
||||
|
||||
$code = $this->generatorDumper->dump(array(
|
||||
$code = $this->generatorDumper->dump([
|
||||
'class' => 'SimpleLocalizedProjectUrlGenerator',
|
||||
));
|
||||
]);
|
||||
file_put_contents($this->testTmpFilepath, $code);
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
@@ -100,7 +100,7 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
$projectUrlGenerator = new \SimpleLocalizedProjectUrlGenerator($context, null, 'en');
|
||||
|
||||
$urlWithDefaultLocale = $projectUrlGenerator->generate('test');
|
||||
$urlWithSpecifiedLocale = $projectUrlGenerator->generate('test', array('_locale' => 'nl'));
|
||||
$urlWithSpecifiedLocale = $projectUrlGenerator->generate('test', ['_locale' => 'nl']);
|
||||
$context->setParameter('_locale', 'en');
|
||||
$urlWithEnglishContext = $projectUrlGenerator->generate('test');
|
||||
$context->setParameter('_locale', 'nl');
|
||||
@@ -127,9 +127,9 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
{
|
||||
$this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test'));
|
||||
|
||||
$code = $this->generatorDumper->dump(array(
|
||||
$code = $this->generatorDumper->dump([
|
||||
'class' => 'RouteNotFoundLocalizedProjectUrlGenerator',
|
||||
));
|
||||
]);
|
||||
file_put_contents($this->testTmpFilepath, $code);
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
@@ -143,9 +143,9 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
$this->routeCollection->add('test.nl', (new Route('/testen/is/leuk'))->setDefault('_canonical_route', 'test'));
|
||||
$this->routeCollection->add('test.fr', (new Route('/tester/est/amusant'))->setDefault('_canonical_route', 'test'));
|
||||
|
||||
$code = $this->generatorDumper->dump(array(
|
||||
$code = $this->generatorDumper->dump([
|
||||
'class' => 'FallbackLocaleLocalizedProjectUrlGenerator',
|
||||
));
|
||||
]);
|
||||
file_put_contents($this->testTmpFilepath, $code);
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
@@ -156,7 +156,7 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
// test with context _locale
|
||||
$this->assertEquals('/app.php/testing/is/fun', $projectUrlGenerator->generate('test'));
|
||||
// test with parameters _locale
|
||||
$this->assertEquals('/app.php/testen/is/leuk', $projectUrlGenerator->generate('test', array('_locale' => 'nl_BE')));
|
||||
$this->assertEquals('/app.php/testen/is/leuk', $projectUrlGenerator->generate('test', ['_locale' => 'nl_BE']));
|
||||
|
||||
$projectUrlGenerator = new \FallbackLocaleLocalizedProjectUrlGenerator(new RequestContext('/app.php'), null, 'fr_CA');
|
||||
// test with default locale
|
||||
@@ -171,18 +171,18 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
}
|
||||
$this->routeCollection->add('Test2', new Route('/testing2'));
|
||||
|
||||
file_put_contents($this->largeTestTmpFilepath, $this->generatorDumper->dump(array(
|
||||
file_put_contents($this->largeTestTmpFilepath, $this->generatorDumper->dump([
|
||||
'class' => 'ProjectLargeUrlGenerator',
|
||||
)));
|
||||
]));
|
||||
$this->routeCollection = $this->generatorDumper = null;
|
||||
include $this->largeTestTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \ProjectLargeUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
|
||||
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
|
||||
@@ -195,12 +195,12 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
*/
|
||||
public function testDumpWithoutRoutes()
|
||||
{
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'WithoutRoutesUrlGenerator')));
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(['class' => 'WithoutRoutesUrlGenerator']));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \WithoutRoutesUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$projectUrlGenerator->generate('Test', array());
|
||||
$projectUrlGenerator->generate('Test', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,45 +210,45 @@ class PhpGeneratorDumperTest extends TestCase
|
||||
{
|
||||
$this->routeCollection->add('Test', new Route('/test'));
|
||||
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'NonExistingRoutesUrlGenerator')));
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(['class' => 'NonExistingRoutesUrlGenerator']));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \NonExistingRoutesUrlGenerator(new RequestContext());
|
||||
$url = $projectUrlGenerator->generate('NonExisting', array());
|
||||
$url = $projectUrlGenerator->generate('NonExisting', []);
|
||||
}
|
||||
|
||||
public function testDumpForRouteWithDefaults()
|
||||
{
|
||||
$this->routeCollection->add('Test', new Route('/testing/{foo}', array('foo' => 'bar')));
|
||||
$this->routeCollection->add('Test', new Route('/testing/{foo}', ['foo' => 'bar']));
|
||||
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'DefaultRoutesUrlGenerator')));
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(['class' => 'DefaultRoutesUrlGenerator']));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \DefaultRoutesUrlGenerator(new RequestContext());
|
||||
$url = $projectUrlGenerator->generate('Test', array());
|
||||
$url = $projectUrlGenerator->generate('Test', []);
|
||||
|
||||
$this->assertEquals('/testing', $url);
|
||||
}
|
||||
|
||||
public function testDumpWithSchemeRequirement()
|
||||
{
|
||||
$this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https')));
|
||||
$this->routeCollection->add('Test1', new Route('/testing', [], [], [], '', ['ftp', 'https']));
|
||||
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator')));
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(['class' => 'SchemeUrlGenerator']));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$absoluteUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('ftp://localhost/app.php/testing', $absoluteUrl);
|
||||
$this->assertEquals('ftp://localhost/app.php/testing', $relativeUrl);
|
||||
|
||||
$projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https'));
|
||||
|
||||
$absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$absoluteUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('https://localhost/app.php/testing', $absoluteUrl);
|
||||
$this->assertEquals('/app.php/testing', $relativeUrl);
|
||||
|
||||
@@ -23,7 +23,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testAbsoluteUrlWithPort80()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing', $url);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testAbsoluteSecureUrlWithPort443()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$url = $this->getGenerator($routes, ['scheme' => 'https'])->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('https://localhost/app.php/testing', $url);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testAbsoluteUrlWithNonStandardPort()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes, array('httpPort' => 8080))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$url = $this->getGenerator($routes, ['httpPort' => 8080])->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost:8080/app.php/testing', $url);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testAbsoluteSecureUrlWithNonStandardPort()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes, array('httpsPort' => 8080, 'scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$url = $this->getGenerator($routes, ['httpsPort' => 8080, 'scheme' => 'https'])->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('https://localhost:8080/app.php/testing', $url);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testRelativeUrlWithoutParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing', $url);
|
||||
}
|
||||
@@ -63,15 +63,15 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testRelativeUrlWithParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing/bar', $url);
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithNullParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing.{format}', array('format' => null)));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$routes = $this->getRoutes('test', new Route('/testing.{format}', ['format' => null]));
|
||||
$url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing', $url);
|
||||
}
|
||||
@@ -81,31 +81,31 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testRelativeUrlWithNullParameterButNotOptional()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', array('foo' => null)));
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', ['foo' => null]));
|
||||
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
|
||||
// Generating path "/testing//bar" would be wrong as matching this route would fail.
|
||||
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithOptionalZeroParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{page}'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('page' => 0), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['page' => 0], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing/0', $url);
|
||||
}
|
||||
|
||||
public function testNotPassedOptionalParameterInBetween()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{slug}/{page}', array('slug' => 'index', 'page' => 0)));
|
||||
$this->assertSame('/app.php/index/1', $this->getGenerator($routes)->generate('test', array('page' => 1)));
|
||||
$routes = $this->getRoutes('test', new Route('/{slug}/{page}', ['slug' => 'index', 'page' => 0]));
|
||||
$this->assertSame('/app.php/index/1', $this->getGenerator($routes)->generate('test', ['page' => 1]));
|
||||
$this->assertSame('/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithExtraParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing?foo=bar', $url);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testAbsoluteUrlWithExtraParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing?foo=bar', $url);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testUrlWithNullExtraParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => null), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['foo' => null], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing', $url);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class UrlGeneratorTest extends TestCase
|
||||
$context = new RequestContext('/app.php');
|
||||
$context->setParameter('bar', 'bar');
|
||||
$generator->setContext($context);
|
||||
$url = $generator->generate('test', array('foo' => 'bar'));
|
||||
$url = $generator->generate('test', ['foo' => 'bar']);
|
||||
|
||||
$this->assertEquals('/app.php/testing?foo=bar', $url);
|
||||
}
|
||||
@@ -145,30 +145,129 @@ class UrlGeneratorTest extends TestCase
|
||||
$context = new RequestContext('/app.php');
|
||||
$context->setParameter('foo', 'bar');
|
||||
$generator->setContext($context);
|
||||
$url = $generator->generate('test', array());
|
||||
$url = $generator->generate('test', []);
|
||||
|
||||
$this->assertEquals('/app.php/testing/bar', $url);
|
||||
}
|
||||
|
||||
public function testGlobalParameterHasHigherPriorityThanDefault()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{_locale}', array('_locale' => 'en')));
|
||||
$routes = $this->getRoutes('test', new Route('/{_locale}', ['_locale' => 'en']));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$context = new RequestContext('/app.php');
|
||||
$context->setParameter('_locale', 'de');
|
||||
$generator->setContext($context);
|
||||
$url = $generator->generate('test', array());
|
||||
$url = $generator->generate('test', []);
|
||||
|
||||
$this->assertSame('/app.php/de', $url);
|
||||
}
|
||||
|
||||
public function testGenerateWithDefaultLocale()
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$route = new Route('');
|
||||
|
||||
$name = 'test';
|
||||
|
||||
foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$localizedRoute->setPath($path);
|
||||
$routes->add($name.'.'.$locale, $localizedRoute);
|
||||
}
|
||||
|
||||
$generator = $this->getGenerator($routes, [], null, 'hr');
|
||||
|
||||
$this->assertSame(
|
||||
'http://localhost/app.php/foo',
|
||||
$generator->generate($name, [], UrlGeneratorInterface::ABSOLUTE_URL)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGenerateWithOverriddenParameterLocale()
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$route = new Route('');
|
||||
|
||||
$name = 'test';
|
||||
|
||||
foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$localizedRoute->setPath($path);
|
||||
$routes->add($name.'.'.$locale, $localizedRoute);
|
||||
}
|
||||
|
||||
$generator = $this->getGenerator($routes, [], null, 'hr');
|
||||
|
||||
$this->assertSame(
|
||||
'http://localhost/app.php/bar',
|
||||
$generator->generate($name, ['_locale' => 'en'], UrlGeneratorInterface::ABSOLUTE_URL)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGenerateWithOverriddenParameterLocaleFromRequestContext()
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$route = new Route('');
|
||||
|
||||
$name = 'test';
|
||||
|
||||
foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$localizedRoute->setPath($path);
|
||||
$routes->add($name.'.'.$locale, $localizedRoute);
|
||||
}
|
||||
|
||||
$generator = $this->getGenerator($routes, [], null, 'hr');
|
||||
|
||||
$context = new RequestContext('/app.php');
|
||||
$context->setParameter('_locale', 'en');
|
||||
$generator->setContext($context);
|
||||
|
||||
$this->assertSame(
|
||||
'http://localhost/app.php/bar',
|
||||
$generator->generate($name, [], UrlGeneratorInterface::ABSOLUTE_URL)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
|
||||
*/
|
||||
public function testGenerateWithoutRoutes()
|
||||
{
|
||||
$routes = $this->getRoutes('foo', new Route('/testing/{foo}'));
|
||||
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
|
||||
*/
|
||||
public function testGenerateWithInvalidLocale()
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$route = new Route('');
|
||||
|
||||
$name = 'test';
|
||||
|
||||
foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$localizedRoute->setPath($path);
|
||||
$routes->add($name.'.'.$locale, $localizedRoute);
|
||||
}
|
||||
|
||||
$generator = $this->getGenerator($routes, [], null, 'fr');
|
||||
$generator->generate($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +276,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testGenerateForRouteWithoutMandatoryParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
||||
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,8 +284,8 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidOptionalParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));
|
||||
$this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,35 +293,35 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '1|2')));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => '0'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '1|2']));
|
||||
$this->getGenerator($routes)->generate('test', ['foo' => '0'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
public function testGenerateForRouteWithInvalidOptionalParameterNonStrict()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->setStrictRequirements(false);
|
||||
$this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
$this->assertNull($generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger->expects($this->once())
|
||||
->method('error');
|
||||
$generator = $this->getGenerator($routes, array(), $logger);
|
||||
$generator = $this->getGenerator($routes, [], $logger);
|
||||
$generator->setStrictRequirements(false);
|
||||
$this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
$this->assertNull($generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->setStrictRequirements(null);
|
||||
$this->assertSame('/app.php/testing/bar', $generator->generate('test', array('foo' => 'bar')));
|
||||
$this->assertSame('/app.php/testing/bar', $generator->generate('test', ['foo' => 'bar']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,8 +329,8 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidMandatoryParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => 'd+')));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => 'd+']));
|
||||
$this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,8 +338,8 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidUtf8Parameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '\pL+'), array('utf8' => true)));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'abc123'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '\pL+'], ['utf8' => true]));
|
||||
$this->getGenerator($routes)->generate('test', ['foo' => 'abc123'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,31 +347,31 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testRequiredParamAndEmptyPassed()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{slug}', array(), array('slug' => '.+')));
|
||||
$this->getGenerator($routes)->generate('test', array('slug' => ''));
|
||||
$routes = $this->getRoutes('test', new Route('/{slug}', [], ['slug' => '.+']));
|
||||
$this->getGenerator($routes)->generate('test', ['slug' => '']);
|
||||
}
|
||||
|
||||
public function testSchemeRequirementDoesNothingIfSameCurrentScheme()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http')));
|
||||
$routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['http']));
|
||||
$this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https')));
|
||||
$this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test'));
|
||||
$routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['https']));
|
||||
$this->assertEquals('/app.php/', $this->getGenerator($routes, ['scheme' => 'https'])->generate('test'));
|
||||
}
|
||||
|
||||
public function testSchemeRequirementForcesAbsoluteUrl()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https')));
|
||||
$routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['https']));
|
||||
$this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http')));
|
||||
$this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test'));
|
||||
$routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['http']));
|
||||
$this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, ['scheme' => 'https'])->generate('test'));
|
||||
}
|
||||
|
||||
public function testSchemeRequirementCreatesUrlForFirstRequiredScheme()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('Ftp', 'https')));
|
||||
$routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['Ftp', 'https']));
|
||||
$this->assertEquals('ftp://localhost/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
@@ -281,48 +380,48 @@ class UrlGeneratorTest extends TestCase
|
||||
$routes = $this->getRoutes('test', new Route('//path-and-not-domain'));
|
||||
|
||||
// this must not generate '//path-and-not-domain' because that would be a network path
|
||||
$this->assertSame('/path-and-not-domain', $this->getGenerator($routes, array('BaseUrl' => ''))->generate('test'));
|
||||
$this->assertSame('/path-and-not-domain', $this->getGenerator($routes, ['BaseUrl' => ''])->generate('test'));
|
||||
}
|
||||
|
||||
public function testNoTrailingSlashForMultipleOptionalParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/category/{slug1}/{slug2}/{slug3}', array('slug2' => null, 'slug3' => null)));
|
||||
$routes = $this->getRoutes('test', new Route('/category/{slug1}/{slug2}/{slug3}', ['slug2' => null, 'slug3' => null]));
|
||||
|
||||
$this->assertEquals('/app.php/category/foo', $this->getGenerator($routes)->generate('test', array('slug1' => 'foo')));
|
||||
$this->assertEquals('/app.php/category/foo', $this->getGenerator($routes)->generate('test', ['slug1' => 'foo']));
|
||||
}
|
||||
|
||||
public function testWithAnIntegerAsADefaultValue()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{default}', array('default' => 0)));
|
||||
$routes = $this->getRoutes('test', new Route('/{default}', ['default' => 0]));
|
||||
|
||||
$this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo')));
|
||||
$this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', ['default' => 'foo']));
|
||||
}
|
||||
|
||||
public function testNullForOptionalParameterIsIgnored()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/test/{default}', array('default' => 0)));
|
||||
$routes = $this->getRoutes('test', new Route('/test/{default}', ['default' => 0]));
|
||||
|
||||
$this->assertEquals('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => null)));
|
||||
$this->assertEquals('/app.php/test', $this->getGenerator($routes)->generate('test', ['default' => null]));
|
||||
}
|
||||
|
||||
public function testQueryParamSameAsDefault()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/test', array('page' => 1)));
|
||||
$routes = $this->getRoutes('test', new Route('/test', ['page' => 1]));
|
||||
|
||||
$this->assertSame('/app.php/test?page=2', $this->getGenerator($routes)->generate('test', array('page' => 2)));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => 1)));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => '1')));
|
||||
$this->assertSame('/app.php/test?page=2', $this->getGenerator($routes)->generate('test', ['page' => 2]));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['page' => 1]));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['page' => '1']));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
public function testArrayQueryParamSameAsDefault()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/test', array('array' => array('foo', 'bar'))));
|
||||
$routes = $this->getRoutes('test', new Route('/test', ['array' => ['foo', 'bar']]));
|
||||
|
||||
$this->assertSame('/app.php/test?array%5B0%5D=bar&array%5B1%5D=foo', $this->getGenerator($routes)->generate('test', array('array' => array('bar', 'foo'))));
|
||||
$this->assertSame('/app.php/test?array%5Ba%5D=foo&array%5Bb%5D=bar', $this->getGenerator($routes)->generate('test', array('array' => array('a' => 'foo', 'b' => 'bar'))));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array('foo', 'bar'))));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array(1 => 'bar', 0 => 'foo'))));
|
||||
$this->assertSame('/app.php/test?array%5B0%5D=bar&array%5B1%5D=foo', $this->getGenerator($routes)->generate('test', ['array' => ['bar', 'foo']]));
|
||||
$this->assertSame('/app.php/test?array%5Ba%5D=foo&array%5Bb%5D=bar', $this->getGenerator($routes)->generate('test', ['array' => ['a' => 'foo', 'b' => 'bar']]));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['array' => ['foo', 'bar']]));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['array' => [1 => 'bar', 0 => 'foo']]));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
@@ -342,11 +441,11 @@ class UrlGeneratorTest extends TestCase
|
||||
// This tests the encoding of reserved characters that are used for delimiting of URI components (defined in RFC 3986)
|
||||
// and other special ASCII chars. These chars are tested as static text path, variable path and query param.
|
||||
$chars = '@:[]/()*\'" +,;-._~&$<>|{}%\\^`!?foo=bar#id';
|
||||
$routes = $this->getRoutes('test', new Route("/$chars/{varpath}", array(), array('varpath' => '.+')));
|
||||
$this->assertSame($expectedPath, $this->getGenerator($routes)->generate('test', array(
|
||||
$routes = $this->getRoutes('test', new Route("/$chars/{varpath}", [], ['varpath' => '.+']));
|
||||
$this->assertSame($expectedPath, $this->getGenerator($routes)->generate('test', [
|
||||
'varpath' => $chars,
|
||||
'query' => $chars,
|
||||
)));
|
||||
]));
|
||||
}
|
||||
|
||||
public function testEncodingOfRelativePathSegments()
|
||||
@@ -361,24 +460,24 @@ class UrlGeneratorTest extends TestCase
|
||||
|
||||
public function testAdjacentVariables()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '\d+')));
|
||||
$routes = $this->getRoutes('test', new Route('/{x}{y}{z}.{_format}', ['z' => 'default-z', '_format' => 'html'], ['y' => '\d+']));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$this->assertSame('/app.php/foo123', $generator->generate('test', array('x' => 'foo', 'y' => '123')));
|
||||
$this->assertSame('/app.php/foo123bar.xml', $generator->generate('test', array('x' => 'foo', 'y' => '123', 'z' => 'bar', '_format' => 'xml')));
|
||||
$this->assertSame('/app.php/foo123', $generator->generate('test', ['x' => 'foo', 'y' => '123']));
|
||||
$this->assertSame('/app.php/foo123bar.xml', $generator->generate('test', ['x' => 'foo', 'y' => '123', 'z' => 'bar', '_format' => 'xml']));
|
||||
|
||||
// The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything
|
||||
// and following optional variables like _format could never match.
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\InvalidParameterException');
|
||||
$generator->generate('test', array('x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml'));
|
||||
$generator->generate('test', ['x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml']);
|
||||
}
|
||||
|
||||
public function testOptionalVariableWithNoRealSeparator()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/get{what}', array('what' => 'All')));
|
||||
$routes = $this->getRoutes('test', new Route('/get{what}', ['what' => 'All']));
|
||||
$generator = $this->getGenerator($routes);
|
||||
|
||||
$this->assertSame('/app.php/get', $generator->generate('test'));
|
||||
$this->assertSame('/app.php/getSites', $generator->generate('test', array('what' => 'Sites')));
|
||||
$this->assertSame('/app.php/getSites', $generator->generate('test', ['what' => 'Sites']));
|
||||
}
|
||||
|
||||
public function testRequiredVariableWithNoRealSeparator()
|
||||
@@ -386,7 +485,7 @@ class UrlGeneratorTest extends TestCase
|
||||
$routes = $this->getRoutes('test', new Route('/get{what}Suffix'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
|
||||
$this->assertSame('/app.php/getSitesSuffix', $generator->generate('test', array('what' => 'Sites')));
|
||||
$this->assertSame('/app.php/getSitesSuffix', $generator->generate('test', ['what' => 'Sites']));
|
||||
}
|
||||
|
||||
public function testDefaultRequirementOfVariable()
|
||||
@@ -394,7 +493,7 @@ class UrlGeneratorTest extends TestCase
|
||||
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
|
||||
$this->assertSame('/app.php/index.mobile.html', $generator->generate('test', array('page' => 'index', '_format' => 'mobile.html')));
|
||||
$this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index', '_format' => 'mobile.html']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,7 +502,7 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testDefaultRequirementOfVariableDisallowsSlash()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
|
||||
$this->getGenerator($routes)->generate('test', array('page' => 'index', '_format' => 'sl/ash'));
|
||||
$this->getGenerator($routes)->generate('test', ['page' => 'index', '_format' => 'sl/ash']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,28 +511,28 @@ class UrlGeneratorTest extends TestCase
|
||||
public function testDefaultRequirementOfVariableDisallowsNextSeparator()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
|
||||
$this->getGenerator($routes)->generate('test', array('page' => 'do.t', '_format' => 'html'));
|
||||
$this->getGenerator($routes)->generate('test', ['page' => 'do.t', '_format' => 'html']);
|
||||
}
|
||||
|
||||
public function testWithHostDifferentFromContext()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com'));
|
||||
|
||||
$this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' => 'Fabien', 'locale' => 'fr')));
|
||||
$this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', ['name' => 'Fabien', 'locale' => 'fr']));
|
||||
}
|
||||
|
||||
public function testWithHostSameAsContext()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com'));
|
||||
|
||||
$this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr')));
|
||||
$this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, ['host' => 'fr.example.com'])->generate('test', ['name' => 'Fabien', 'locale' => 'fr']));
|
||||
}
|
||||
|
||||
public function testWithHostSameAsContextAndAbsolute()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com'));
|
||||
|
||||
$this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
$this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, ['host' => 'fr.example.com'])->generate('test', ['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,8 +540,8 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testUrlWithInvalidParameterInHost()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$routes = $this->getRoutes('test', new Route('/', [], ['foo' => 'bar'], [], '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,8 +549,8 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'bar'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$routes = $this->getRoutes('test', new Route('/', ['foo' => 'bar'], ['foo' => 'bar'], [], '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,72 +558,72 @@ class UrlGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testUrlWithInvalidParameterEqualsDefaultValueInHost()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'baz'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$routes = $this->getRoutes('test', new Route('/', ['foo' => 'baz'], ['foo' => 'bar'], [], '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
public function testUrlWithInvalidParameterInHostInNonStrictMode()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$routes = $this->getRoutes('test', new Route('/', [], ['foo' => 'bar'], [], '{foo}.example.com'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->setStrictRequirements(false);
|
||||
$this->assertNull($generator->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH));
|
||||
$this->assertNull($generator->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH));
|
||||
}
|
||||
|
||||
public function testHostIsCaseInsensitive()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array('locale' => 'en|de|fr'), array(), '{locale}.FooBar.com'));
|
||||
$routes = $this->getRoutes('test', new Route('/', [], ['locale' => 'en|de|fr'], [], '{locale}.FooBar.com'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$this->assertSame('//EN.FooBar.com/app.php/', $generator->generate('test', array('locale' => 'EN'), UrlGeneratorInterface::NETWORK_PATH));
|
||||
$this->assertSame('//EN.FooBar.com/app.php/', $generator->generate('test', ['locale' => 'EN'], UrlGeneratorInterface::NETWORK_PATH));
|
||||
}
|
||||
|
||||
public function testDefaultHostIsUsedWhenContextHostIsEmpty()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/route', array('domain' => 'my.fallback.host'), array('domain' => '.+'), array(), '{domain}', array('http')));
|
||||
$routes = $this->getRoutes('test', new Route('/route', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}', ['http']));
|
||||
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->getContext()->setHost('');
|
||||
|
||||
$this->assertSame('http://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
$this->assertSame('http://my.fallback.host/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/route', array('domain' => 'my.fallback.host'), array('domain' => '.+'), array(), '{domain}', array('http', 'https')));
|
||||
$routes = $this->getRoutes('test', new Route('/route', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}', ['http', 'https']));
|
||||
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->getContext()->setHost('');
|
||||
$generator->getContext()->setScheme('https');
|
||||
|
||||
$this->assertSame('https://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
$this->assertSame('https://my.fallback.host/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/route', array(), array(), array(), '', array('http', 'https')));
|
||||
$routes = $this->getRoutes('test', new Route('/route', [], [], [], '', ['http', 'https']));
|
||||
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->getContext()->setHost('');
|
||||
$generator->getContext()->setScheme('https');
|
||||
|
||||
$this->assertSame('/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
$this->assertSame('/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testGenerateNetworkPath()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com', array('http')));
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com', ['http']));
|
||||
|
||||
$this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host'
|
||||
['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::NETWORK_PATH), 'network path with different host'
|
||||
);
|
||||
$this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context'
|
||||
$this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, ['host' => 'fr.example.com'])->generate('test',
|
||||
['name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'], UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context'
|
||||
);
|
||||
$this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context'
|
||||
$this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, ['scheme' => 'https'])->generate('test',
|
||||
['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context'
|
||||
);
|
||||
$this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested'
|
||||
['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -533,32 +632,32 @@ class UrlGeneratorTest extends TestCase
|
||||
$routes = new RouteCollection();
|
||||
$routes->add('article', new Route('/{author}/{article}/'));
|
||||
$routes->add('comments', new Route('/{author}/{article}/comments'));
|
||||
$routes->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com'));
|
||||
$routes->add('scheme', new Route('/{author}/blog', array(), array(), array(), '', array('https')));
|
||||
$routes->add('host', new Route('/{article}', [], [], [], '{author}.example.com'));
|
||||
$routes->add('scheme', new Route('/{author}/blog', [], [], [], '', ['https']));
|
||||
$routes->add('unrelated', new Route('/about'));
|
||||
|
||||
$generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/'));
|
||||
$generator = $this->getGenerator($routes, ['host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/']);
|
||||
|
||||
$this->assertSame('comments', $generator->generate('comments',
|
||||
array('author' => 'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
['author' => 'fabien', 'article' => 'symfony-is-great'], UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('comments?page=2', $generator->generate('comments',
|
||||
array('author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
['author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2], UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('../twig-is-great/', $generator->generate('article',
|
||||
array('author' => 'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
['author' => 'fabien', 'article' => 'twig-is-great'], UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article',
|
||||
array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
['author' => 'bernhard', 'article' => 'forms-are-great'], UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host',
|
||||
array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
['author' => 'bernhard', 'article' => 'forms-are-great'], UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme',
|
||||
array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
['author' => 'bernhard'], UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('../../about', $generator->generate('unrelated',
|
||||
array(), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
[], UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -572,138 +671,155 @@ class UrlGeneratorTest extends TestCase
|
||||
|
||||
public function provideRelativePaths()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'/same/dir/',
|
||||
'/same/dir/',
|
||||
'',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/same/file',
|
||||
'/same/file',
|
||||
'',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/',
|
||||
'/file',
|
||||
'file',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/',
|
||||
'/dir/file',
|
||||
'dir/file',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/dir/file.html',
|
||||
'/dir/different-file.html',
|
||||
'different-file.html',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/same/dir/extra-file',
|
||||
'/same/dir/',
|
||||
'./',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/parent/dir/',
|
||||
'/parent/',
|
||||
'../',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/parent/dir/extra-file',
|
||||
'/parent/',
|
||||
'../',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/a/b/',
|
||||
'/x/y/z/',
|
||||
'../../x/y/z/',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/a/b/c/d/e',
|
||||
'/a/c/d',
|
||||
'../../../c/d',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/a/b/c//',
|
||||
'/a/b/c/',
|
||||
'../',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/a/b/c/',
|
||||
'/a/b/c//',
|
||||
'.//',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/root/a/b/c/',
|
||||
'/root/x/b/c/',
|
||||
'../../../x/b/c/',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/a/b/c/d/',
|
||||
'/a',
|
||||
'../../../../a',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/special-chars/sp%20ce/1€/mäh/e=mc²',
|
||||
'/special-chars/sp%20ce/1€/<µ>/e=mc²',
|
||||
'../<µ>/e=mc²',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'not-rooted',
|
||||
'dir/file',
|
||||
'dir/file',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'//dir/',
|
||||
'',
|
||||
'../../',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/dir/',
|
||||
'/dir/file:with-colon',
|
||||
'./file:with-colon',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/dir/',
|
||||
'/dir/subdir/file:with-colon',
|
||||
'subdir/file:with-colon',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/dir/',
|
||||
'/dir/:subdir/',
|
||||
'./:subdir/',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testFragmentsCanBeAppendedToUrls()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
|
||||
$url = $this->getGenerator($routes)->generate('test', array('_fragment' => 'frag ment'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['_fragment' => 'frag ment'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$this->assertEquals('/app.php/testing#frag%20ment', $url);
|
||||
|
||||
$url = $this->getGenerator($routes)->generate('test', array('_fragment' => '0'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['_fragment' => '0'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$this->assertEquals('/app.php/testing#0', $url);
|
||||
}
|
||||
|
||||
public function testFragmentsDoNotEscapeValidCharacters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('_fragment' => '?/'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$url = $this->getGenerator($routes)->generate('test', ['_fragment' => '?/'], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing#?/', $url);
|
||||
}
|
||||
|
||||
public function testFragmentsCanBeDefinedAsDefaults()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing', array('_fragment' => 'fragment')));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$routes = $this->getRoutes('test', new Route('/testing', ['_fragment' => 'fragment']));
|
||||
$url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing#fragment', $url);
|
||||
}
|
||||
|
||||
protected function getGenerator(RouteCollection $routes, array $parameters = array(), $logger = null)
|
||||
/**
|
||||
* @dataProvider provideLookAroundRequirementsInPath
|
||||
*/
|
||||
public function testLookRoundRequirementsInPath($expected, $path, $requirement)
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route($path, [], ['foo' => $requirement, 'baz' => '.+?']));
|
||||
$this->assertSame($expected, $this->getGenerator($routes)->generate('test', ['foo' => 'a/b', 'baz' => 'c/d/e']));
|
||||
}
|
||||
|
||||
public function provideLookAroundRequirementsInPath()
|
||||
{
|
||||
yield ['/app.php/a/b/b%28ar/c/d/e', '/{foo}/b(ar/{baz}', '.+(?=/b\\(ar/)'];
|
||||
yield ['/app.php/a/b/bar/c/d/e', '/{foo}/bar/{baz}', '.+(?!$)'];
|
||||
yield ['/app.php/bar/a/b/bam/c/d/e', '/bar/{foo}/bam/{baz}', '(?<=/bar/).+'];
|
||||
yield ['/app.php/bar/a/b/bam/c/d/e', '/bar/{foo}/bam/{baz}', '(?<!^).+'];
|
||||
}
|
||||
|
||||
protected function getGenerator(RouteCollection $routes, array $parameters = [], $logger = null, string $defaultLocale = null)
|
||||
{
|
||||
$context = new RequestContext('/app.php');
|
||||
foreach ($parameters as $key => $value) {
|
||||
@@ -711,7 +827,7 @@ class UrlGeneratorTest extends TestCase
|
||||
$context->$method($value);
|
||||
}
|
||||
|
||||
return new UrlGenerator($routes, $context, $logger);
|
||||
return new UrlGenerator($routes, $context, $logger, $defaultLocale);
|
||||
}
|
||||
|
||||
protected function getRoutes($name, Route $route)
|
||||
|
||||
@@ -26,7 +26,7 @@ abstract class AbstractAnnotationLoaderTest extends TestCase
|
||||
public function getClassLoader($reader)
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader')
|
||||
->setConstructorArgs(array($reader))
|
||||
->setConstructorArgs([$reader])
|
||||
->getMockForAbstractClass()
|
||||
;
|
||||
}
|
||||
|
||||
@@ -64,15 +64,15 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function provideTestSupportsChecksResource()
|
||||
{
|
||||
return array(
|
||||
array('class', true),
|
||||
array('\fully\qualified\class\name', true),
|
||||
array('namespaced\class\without\leading\slash', true),
|
||||
array('ÿClassWithLegalSpecialCharacters', true),
|
||||
array('5', false),
|
||||
array('foo.foo', false),
|
||||
array(null, false),
|
||||
);
|
||||
return [
|
||||
['class', true],
|
||||
['\fully\qualified\class\name', true],
|
||||
['namespaced\class\without\leading\slash', true],
|
||||
['ÿClassWithLegalSpecialCharacters', true],
|
||||
['5', false],
|
||||
['foo.foo', false],
|
||||
[null, false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testSupportsChecksTypeIfSpecified()
|
||||
@@ -105,8 +105,8 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$routes = $this->loader->load(InvokableController::class);
|
||||
$this->assertCount(1, $routes);
|
||||
$this->assertEquals('/here', $routes->get('lol')->getPath());
|
||||
$this->assertEquals(array('GET', 'POST'), $routes->get('lol')->getMethods());
|
||||
$this->assertEquals(array('https'), $routes->get('lol')->getSchemes());
|
||||
$this->assertEquals(['GET', 'POST'], $routes->get('lol')->getMethods());
|
||||
$this->assertEquals(['https'], $routes->get('lol')->getSchemes());
|
||||
}
|
||||
|
||||
public function testInvokableLocalizedControllerLoading()
|
||||
@@ -136,9 +136,11 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
public function testDefaultValuesForMethods()
|
||||
{
|
||||
$routes = $this->loader->load(DefaultValueController::class);
|
||||
$this->assertCount(1, $routes);
|
||||
$this->assertCount(3, $routes);
|
||||
$this->assertEquals('/{default}/path', $routes->get('action')->getPath());
|
||||
$this->assertEquals('value', $routes->get('action')->getDefault('default'));
|
||||
$this->assertEquals('Symfony', $routes->get('hello_with_default')->getDefault('name'));
|
||||
$this->assertEquals('World', $routes->get('hello_without_default')->getDefault('name'));
|
||||
}
|
||||
|
||||
public function testMethodActionControllers()
|
||||
@@ -185,30 +187,30 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function testInvokableClassMultipleRouteLoad()
|
||||
{
|
||||
$classRouteData1 = array(
|
||||
$classRouteData1 = [
|
||||
'name' => 'route1',
|
||||
'path' => '/1',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
'schemes' => ['https'],
|
||||
'methods' => ['GET'],
|
||||
];
|
||||
|
||||
$classRouteData2 = array(
|
||||
$classRouteData2 = [
|
||||
'name' => 'route2',
|
||||
'path' => '/2',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
'schemes' => ['https'],
|
||||
'methods' => ['GET'],
|
||||
];
|
||||
|
||||
$reader = $this->getReader();
|
||||
$reader
|
||||
->expects($this->exactly(1))
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array(new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2))))
|
||||
->will($this->returnValue([new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2)]))
|
||||
;
|
||||
$reader
|
||||
->expects($this->once())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
$loader = new class($reader) extends AnnotationClassLoader {
|
||||
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
|
||||
|
||||
@@ -34,13 +34,13 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
@@ -48,22 +48,22 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function testLoadIgnoresHiddenDirectories()
|
||||
{
|
||||
$this->expectAnnotationsToBeReadFrom(array(
|
||||
$this->expectAnnotationsToBeReadFrom([
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
|
||||
));
|
||||
]);
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
@@ -92,7 +92,7 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
|
||||
|
||||
@@ -53,10 +53,10 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function testLoadVariadic()
|
||||
{
|
||||
$route = new Route(array('path' => '/path/to/{id}'));
|
||||
$route = new Route(['path' => '/path/to/{id}']);
|
||||
$this->reader->expects($this->once())->method('getClassAnnotation');
|
||||
$this->reader->expects($this->once())->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array($route)));
|
||||
->will($this->returnValue([$route]));
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
|
||||
}
|
||||
@@ -72,6 +72,14 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php');
|
||||
}
|
||||
|
||||
public function testLoadAbstractClass()
|
||||
{
|
||||
$this->reader->expects($this->never())->method('getClassAnnotation');
|
||||
$this->reader->expects($this->never())->method('getMethodAnnotations');
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/AbstractClass.php');
|
||||
}
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$fixture = __DIR__.'/../Fixtures/annotated.php';
|
||||
|
||||
@@ -30,11 +30,11 @@ class DirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$locator = new FileLocator();
|
||||
$this->reader = $this->getReader();
|
||||
$this->loader = new DirectoryLoader($locator);
|
||||
$resolver = new LoaderResolver(array(
|
||||
$resolver = new LoaderResolver([
|
||||
new YamlFileLoader($locator),
|
||||
new AnnotationFileLoader($locator, $this->getClassLoader($this->reader)),
|
||||
$this->loader,
|
||||
));
|
||||
]);
|
||||
$this->loader->setResolver($resolver);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user