composer update
This commit is contained in:
3
vendor/symfony/routing/.gitattributes
vendored
3
vendor/symfony/routing/.gitattributes
vendored
@@ -1,3 +0,0 @@
|
||||
/Tests export-ignore
|
||||
/phpunit.xml.dist export-ignore
|
||||
/.gitignore export-ignore
|
||||
7
vendor/symfony/routing/Annotation/Route.php
vendored
7
vendor/symfony/routing/Annotation/Route.php
vendored
@@ -31,9 +31,6 @@ class Route
|
||||
private $methods = [];
|
||||
private $schemes = [];
|
||||
private $condition;
|
||||
private $locale;
|
||||
private $format;
|
||||
private $utf8;
|
||||
|
||||
/**
|
||||
* @param array $data An array of key/value parameters
|
||||
@@ -43,7 +40,7 @@ class Route
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (isset($data['localized_paths'])) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', \get_class($this)));
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', static::class));
|
||||
}
|
||||
|
||||
if (isset($data['value'])) {
|
||||
@@ -74,7 +71,7 @@ class Route
|
||||
foreach ($data as $key => $value) {
|
||||
$method = 'set'.str_replace('_', '', $key);
|
||||
if (!method_exists($this, $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, \get_class($this)));
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, static::class));
|
||||
}
|
||||
$this->$method($value);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ class CompiledUrlGenerator extends UrlGenerator
|
||||
if (null !== $locale) {
|
||||
do {
|
||||
if (($this->compiledRoutes[$name.'.'.$locale][1]['_canonical_route'] ?? null) === $name) {
|
||||
unset($parameters['_locale']);
|
||||
$name .= '.'.$locale;
|
||||
break;
|
||||
}
|
||||
@@ -53,6 +52,14 @@ class CompiledUrlGenerator extends UrlGenerator
|
||||
|
||||
list($variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes) = $this->compiledRoutes[$name];
|
||||
|
||||
if (isset($defaults['_canonical_route']) && isset($defaults['_locale'])) {
|
||||
if (!\in_array('_locale', $variables, true)) {
|
||||
unset($parameters['_locale']);
|
||||
} elseif (!isset($parameters['_locale'])) {
|
||||
$parameters['_locale'] = $defaults['_locale'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,6 @@ EOF;
|
||||
if (null !== $locale && null !== $name) {
|
||||
do {
|
||||
if ((self::$declaredRoutes[$name.'.'.$locale][1]['_canonical_route'] ?? null) === $name) {
|
||||
unset($parameters['_locale']);
|
||||
$name .= '.'.$locale;
|
||||
break;
|
||||
}
|
||||
@@ -129,6 +128,14 @@ EOF;
|
||||
|
||||
list($variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes) = self::$declaredRoutes[$name];
|
||||
|
||||
if (isset($defaults['_canonical_route']) && isset($defaults['_locale'])) {
|
||||
if (!\in_array('_locale', $variables, true)) {
|
||||
unset($parameters['_locale']);
|
||||
} elseif (!isset($parameters['_locale'])) {
|
||||
$parameters['_locale'] = $defaults['_locale'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
|
||||
}
|
||||
EOF;
|
||||
|
||||
@@ -134,7 +134,6 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
if (null !== $locale) {
|
||||
do {
|
||||
if (null !== ($route = $this->routes->get($name.'.'.$locale)) && $route->getDefault('_canonical_route') === $name) {
|
||||
unset($parameters['_locale']);
|
||||
break;
|
||||
}
|
||||
} while (false !== $locale = strstr($locale, '_', true));
|
||||
@@ -147,7 +146,18 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
// the Route has a cache of its own and is not recompiled as long as it does not get modified
|
||||
$compiledRoute = $route->compile();
|
||||
|
||||
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes());
|
||||
$defaults = $route->getDefaults();
|
||||
$variables = $compiledRoute->getVariables();
|
||||
|
||||
if (isset($defaults['_canonical_route']) && isset($defaults['_locale'])) {
|
||||
if (!\in_array('_locale', $variables, true)) {
|
||||
unset($parameters['_locale']);
|
||||
} elseif (!isset($parameters['_locale'])) {
|
||||
$parameters['_locale'] = $defaults['_locale'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doGenerate($variables, $defaults, $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
vendor/symfony/routing/LICENSE
vendored
2
vendor/symfony/routing/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2019 Fabien Potencier
|
||||
Copyright (c) 2004-2020 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -18,6 +18,7 @@ use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Annotation\Route as RouteAnnotation;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
/**
|
||||
* AnnotationClassLoader loads routing information from a PHP class and its methods.
|
||||
@@ -211,6 +212,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
$this->configureRoute($route, $class, $method, $annot);
|
||||
if (0 !== $locale) {
|
||||
$route->setDefault('_locale', $locale);
|
||||
$route->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER));
|
||||
$route->setDefault('_canonical_route', $name);
|
||||
$collection->add($name.'.'.$locale, $route);
|
||||
} else {
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
@@ -63,6 +64,7 @@ class ImportConfigurator
|
||||
foreach ($prefix as $locale => $localePrefix) {
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER));
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
|
||||
$this->route->add($name.'.'.$locale, $localizedRoute);
|
||||
|
||||
@@ -15,6 +15,7 @@ use Symfony\Component\Routing\Loader\Configurator\CollectionConfigurator;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
trait AddTrait
|
||||
{
|
||||
@@ -67,6 +68,7 @@ trait AddTrait
|
||||
$routes->add($name.'.'.$locale, $route = $this->createRoute($path));
|
||||
$this->collection->add($this->name.$name.'.'.$locale, $route);
|
||||
$route->setDefault('_locale', $locale);
|
||||
$route->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER));
|
||||
$route->setDefault('_canonical_route', $this->name.$name);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,11 +57,11 @@ abstract class ObjectLoader extends Loader
|
||||
$loaderObject = $this->getObject($parts[0]);
|
||||
|
||||
if (!\is_object($loaderObject)) {
|
||||
throw new \TypeError(sprintf('%s:getObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
|
||||
throw new \TypeError(sprintf('"%s:getObject()" must return an object: "%s" returned.', static::class, \gettype($loaderObject)));
|
||||
}
|
||||
|
||||
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));
|
||||
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s".', $method, \get_class($loaderObject), $resource));
|
||||
}
|
||||
|
||||
$routeCollection = $loaderObject->$method($this);
|
||||
@@ -69,7 +69,7 @@ abstract class ObjectLoader extends Loader
|
||||
if (!$routeCollection instanceof RouteCollection) {
|
||||
$type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection);
|
||||
|
||||
throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', \get_class($loaderObject), $method, $type));
|
||||
throw new \LogicException(sprintf('The "%s::%s()" method must return a RouteCollection: "%s" returned.', \get_class($loaderObject), $method, $type));
|
||||
}
|
||||
|
||||
// make the object file tracked so that if it changes, the cache rebuilds
|
||||
|
||||
@@ -16,6 +16,7 @@ use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
/**
|
||||
* XmlFileLoader loads XML routing files.
|
||||
@@ -129,6 +130,7 @@ class XmlFileLoader extends FileLoader
|
||||
foreach ($paths as $locale => $p) {
|
||||
$defaults['_locale'] = $locale;
|
||||
$defaults['_canonical_route'] = $id;
|
||||
$requirements['_locale'] = preg_quote($locale, RouteCompiler::REGEX_DELIMITER);
|
||||
$route = new Route($p, $defaults, $requirements, $options, $node->getAttribute('host'), $schemes, $methods, $condition);
|
||||
$collection->add($id.'.'.$locale, $route);
|
||||
}
|
||||
@@ -209,6 +211,7 @@ class XmlFileLoader extends FileLoader
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER));
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$subCollection->add($name.'.'.$locale, $localizedRoute);
|
||||
}
|
||||
@@ -312,9 +315,9 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
if ($controller = $node->getAttribute('controller')) {
|
||||
if (isset($defaults['_controller'])) {
|
||||
$name = $node->hasAttribute('id') ? sprintf('"%s"', $node->getAttribute('id')) : sprintf('the "%s" tag', $node->tagName);
|
||||
$name = $node->hasAttribute('id') ? sprintf('"%s".', $node->getAttribute('id')) : sprintf('the "%s" tag.', $node->tagName);
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" attribute and the defaults key "_controller" for %s.', $path, $name));
|
||||
throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" attribute and the defaults key "_controller" for ', $path).$name);
|
||||
}
|
||||
|
||||
$defaults['_controller'] = $controller;
|
||||
|
||||
@@ -15,6 +15,7 @@ use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
@@ -140,6 +141,7 @@ class YamlFileLoader extends FileLoader
|
||||
foreach ($config['path'] as $locale => $path) {
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER));
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$localizedRoute->setPath($path);
|
||||
$collection->add($name.'.'.$locale, $localizedRoute);
|
||||
@@ -214,6 +216,7 @@ class YamlFileLoader extends FileLoader
|
||||
foreach ($prefix as $locale => $localePrefix) {
|
||||
$localizedRoute = clone $route;
|
||||
$localizedRoute->setDefault('_locale', $locale);
|
||||
$localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER));
|
||||
$localizedRoute->setDefault('_canonical_route', $name);
|
||||
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
|
||||
$subCollection->add($name.'.'.$locale, $localizedRoute);
|
||||
|
||||
40
vendor/symfony/routing/README.md
vendored
40
vendor/symfony/routing/README.md
vendored
@@ -3,10 +3,48 @@ Routing Component
|
||||
|
||||
The Routing component maps an HTTP request to a set of configuration variables.
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
|
||||
```
|
||||
$ composer require symfony/routing
|
||||
```
|
||||
|
||||
```php
|
||||
use App\Controller\BlogController;
|
||||
use Symfony\Component\Routing\Generator\UrlGenerator;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
$route = new Route('/blog/{slug}', ['_controller' => BlogController::class]);
|
||||
$routes = new RouteCollection();
|
||||
$routes->add('blog_show', $route);
|
||||
|
||||
$context = new RequestContext();
|
||||
|
||||
// Routing can match routes with incoming requests
|
||||
$matcher = new UrlMatcher($routes, $context);
|
||||
$parameters = $matcher->match('/blog/lorem-ipsum');
|
||||
// $parameters = [
|
||||
// '_controller' => 'App\Controller\BlogController',
|
||||
// 'slug' => 'lorem-ipsum',
|
||||
// '_route' => 'blog_show'
|
||||
// ]
|
||||
|
||||
// Routing can also generate URLs for a given route
|
||||
$generator = new UrlGenerator($routes, $context);
|
||||
$url = $generator->generate('blog_show', [
|
||||
'slug' => 'my-blog-post',
|
||||
]);
|
||||
// $url = '/blog/my-blog-post'
|
||||
```
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/routing/index.html)
|
||||
* [Documentation](https://symfony.com/doc/current/routing.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
|
||||
21
vendor/symfony/routing/Route.php
vendored
21
vendor/symfony/routing/Route.php
vendored
@@ -376,6 +376,10 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function addDefaults(array $defaults)
|
||||
{
|
||||
if (isset($defaults['_locale']) && $this->isLocalized()) {
|
||||
unset($defaults['_locale']);
|
||||
}
|
||||
|
||||
foreach ($defaults as $name => $default) {
|
||||
$this->defaults[$name] = $default;
|
||||
}
|
||||
@@ -418,6 +422,10 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function setDefault($name, $default)
|
||||
{
|
||||
if ('_locale' === $name && $this->isLocalized()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->defaults[$name] = $default;
|
||||
$this->compiled = null;
|
||||
|
||||
@@ -461,6 +469,10 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function addRequirements(array $requirements)
|
||||
{
|
||||
if (isset($requirements['_locale']) && $this->isLocalized()) {
|
||||
unset($requirements['_locale']);
|
||||
}
|
||||
|
||||
foreach ($requirements as $key => $regex) {
|
||||
$this->requirements[$key] = $this->sanitizeRequirement($key, $regex);
|
||||
}
|
||||
@@ -503,6 +515,10 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function setRequirement($key, $regex)
|
||||
{
|
||||
if ('_locale' === $key && $this->isLocalized()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->requirements[$key] = $this->sanitizeRequirement($key, $regex);
|
||||
$this->compiled = null;
|
||||
|
||||
@@ -577,4 +593,9 @@ class Route implements \Serializable
|
||||
|
||||
return $regex;
|
||||
}
|
||||
|
||||
private function isLocalized(): bool
|
||||
{
|
||||
return isset($this->defaults['_locale']) && isset($this->defaults['_canonical_route']) && ($this->requirements['_locale'] ?? null) === preg_quote($this->defaults['_locale'], RouteCompiler::REGEX_DELIMITER);
|
||||
}
|
||||
}
|
||||
|
||||
10
vendor/symfony/routing/RouteCompiler.php
vendored
10
vendor/symfony/routing/RouteCompiler.php
vendored
@@ -61,6 +61,14 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$hostRegex = $result['regex'];
|
||||
}
|
||||
|
||||
$locale = $route->getDefault('_locale');
|
||||
if (null !== $locale && null !== $route->getDefault('_canonical_route') && preg_quote($locale, self::REGEX_DELIMITER) === $route->getRequirement('_locale')) {
|
||||
$requirements = $route->getRequirements();
|
||||
unset($requirements['_locale']);
|
||||
$route->setRequirements($requirements);
|
||||
$route->setPath(str_replace('{_locale}', $locale, $route->getPath()));
|
||||
}
|
||||
|
||||
$path = $route->getPath();
|
||||
|
||||
$result = self::compilePattern($route, $path, false);
|
||||
@@ -139,7 +147,7 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
}
|
||||
|
||||
if (\strlen($varName) > self::VARIABLE_MAXIMUM_LENGTH) {
|
||||
throw new \DomainException(sprintf('Variable name "%s" cannot be longer than %s characters in route pattern "%s". Please use a shorter name.', $varName, self::VARIABLE_MAXIMUM_LENGTH, $pattern));
|
||||
throw new \DomainException(sprintf('Variable name "%s" cannot be longer than %d characters in route pattern "%s". Please use a shorter name.', $varName, self::VARIABLE_MAXIMUM_LENGTH, $pattern));
|
||||
}
|
||||
|
||||
if ($isSeparator && $precedingText !== $precedingChar) {
|
||||
|
||||
35
vendor/symfony/routing/Router.php
vendored
35
vendor/symfony/routing/Router.php
vendored
@@ -97,6 +97,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
private $expressionLanguageProviders = [];
|
||||
|
||||
private static $cache = [];
|
||||
|
||||
/**
|
||||
* @param mixed $resource The main resource to load
|
||||
*/
|
||||
@@ -283,7 +285,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
return $this->matcher;
|
||||
}
|
||||
|
||||
$compiled = is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) && (UrlMatcher::class === $this->options['matcher_base_class'] || RedirectableUrlMatcher::class === $this->options['matcher_base_class']);
|
||||
$compiled = is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) && (UrlMatcher::class === $this->options['matcher_base_class'] || RedirectableUrlMatcher::class === $this->options['matcher_base_class']) && is_a($this->options['matcher_dumper_class'], CompiledUrlMatcherDumper::class, true);
|
||||
|
||||
if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) {
|
||||
$routes = $this->getRouteCollection();
|
||||
@@ -319,7 +321,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
);
|
||||
|
||||
if ($compiled) {
|
||||
return $this->matcher = new $this->options['matcher_class'](require $cache->getPath(), $this->context);
|
||||
return $this->matcher = new $this->options['matcher_class'](self::getCompiledRoutes($cache->getPath()), $this->context);
|
||||
}
|
||||
|
||||
if (!class_exists($this->options['matcher_cache_class'], false)) {
|
||||
@@ -340,7 +342,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
return $this->generator;
|
||||
}
|
||||
|
||||
$compiled = is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && UrlGenerator::class === $this->options['generator_base_class'];
|
||||
$compiled = is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && UrlGenerator::class === $this->options['generator_base_class'] && is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true);
|
||||
|
||||
if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
|
||||
$routes = $this->getRouteCollection();
|
||||
@@ -363,7 +365,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
);
|
||||
|
||||
if ($compiled) {
|
||||
$this->generator = new $this->options['generator_class'](require $cache->getPath(), $this->context, $this->logger, $this->defaultLocale);
|
||||
$this->generator = new $this->options['generator_class'](self::getCompiledRoutes($cache->getPath()), $this->context, $this->logger, $this->defaultLocale);
|
||||
} else {
|
||||
if (!class_exists($this->options['generator_cache_class'], false)) {
|
||||
require_once $cache->getPath();
|
||||
@@ -390,8 +392,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
protected function getGeneratorDumperInstance()
|
||||
{
|
||||
// For BC, fallback to PhpGeneratorDumper if the UrlGenerator and UrlGeneratorDumper are not consistent with each other
|
||||
if (is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) !== is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true)) {
|
||||
// For BC, fallback to PhpGeneratorDumper (which is the old default value) if the old UrlGenerator is used with the new default CompiledUrlGeneratorDumper
|
||||
if (!is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true)) {
|
||||
return new PhpGeneratorDumper($this->getRouteCollection());
|
||||
}
|
||||
|
||||
@@ -403,8 +405,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
protected function getMatcherDumperInstance()
|
||||
{
|
||||
// For BC, fallback to PhpMatcherDumper if the UrlMatcher and UrlMatcherDumper are not consistent with each other
|
||||
if (is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) !== is_a($this->options['matcher_dumper_class'], CompiledUrlMatcherDumper::class, true)) {
|
||||
// For BC, fallback to PhpMatcherDumper (which is the old default value) if the old UrlMatcher is used with the new default CompiledUrlMatcherDumper
|
||||
if (!is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) && is_a($this->options['matcher_dumper_class'], CompiledUrlMatcherDumper::class, true)) {
|
||||
return new PhpMatcherDumper($this->getRouteCollection());
|
||||
}
|
||||
|
||||
@@ -434,4 +436,21 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
@trigger_error(sprintf('Option "%s" given to router %s is deprecated since Symfony 4.3.', $key, static::class), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getCompiledRoutes(string $path): array
|
||||
{
|
||||
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
|
||||
self::$cache = null;
|
||||
}
|
||||
|
||||
if (null === self::$cache) {
|
||||
return require $path;
|
||||
}
|
||||
|
||||
if (isset(self::$cache[$path])) {
|
||||
return self::$cache[$path];
|
||||
}
|
||||
|
||||
return self::$cache[$path] = require $path;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user