composer update
This commit is contained in:
@@ -15,6 +15,7 @@ use Doctrine\Common\Annotations\Reader;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Annotation\Route as RouteAnnotation;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
@@ -32,7 +33,6 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
* recognizes several parameters: requirements, options, defaults, schemes,
|
||||
* methods, host, and name. The name parameter is mandatory.
|
||||
* Here is an example of how you should be able to use it:
|
||||
*
|
||||
* /**
|
||||
* * @Route("/Blog")
|
||||
* * /
|
||||
@@ -44,7 +44,6 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
* public function index()
|
||||
* {
|
||||
* }
|
||||
*
|
||||
* /**
|
||||
* * @Route("/{id}", name="blog_post", requirements = {"id" = "\d+"})
|
||||
* * /
|
||||
@@ -131,6 +130,10 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RouteAnnotation $annot or an object that exposes a similar interface
|
||||
* @param array $globals
|
||||
*/
|
||||
protected function addRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method)
|
||||
{
|
||||
$name = $annot->getName();
|
||||
@@ -241,9 +244,6 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
/**
|
||||
* Gets the default route name for a class method.
|
||||
*
|
||||
* @param \ReflectionClass $class
|
||||
* @param \ReflectionMethod $method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
|
||||
|
||||
@@ -46,7 +46,7 @@ class AnnotationFileLoader extends FileLoader
|
||||
* @param string $file A PHP file path
|
||||
* @param string|null $type The resource type
|
||||
*
|
||||
* @return RouteCollection A RouteCollection instance
|
||||
* @return RouteCollection|null A RouteCollection instance
|
||||
*
|
||||
* @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ class AnnotationFileLoader extends FileLoader
|
||||
if ($class = $this->findClass($path)) {
|
||||
$refl = new \ReflectionClass($class);
|
||||
if ($refl->isAbstract()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$collection->addResource(new FileResource($path));
|
||||
|
||||
@@ -47,10 +47,8 @@ class CollectionConfigurator
|
||||
|
||||
/**
|
||||
* Creates a sub-collection.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
final public function collection($name = '')
|
||||
final public function collection(string $name = ''): self
|
||||
{
|
||||
return new self($this->collection, $this->name.$name, $this, $this->prefixes);
|
||||
}
|
||||
@@ -62,7 +60,7 @@ class CollectionConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function prefix($prefix)
|
||||
final public function prefix($prefix): self
|
||||
{
|
||||
if (\is_array($prefix)) {
|
||||
if (null === $this->parentPrefixes) {
|
||||
@@ -88,7 +86,7 @@ class CollectionConfigurator
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function createRoute($path): Route
|
||||
private function createRoute(string $path): Route
|
||||
{
|
||||
return (clone $this->route)->setPath($path);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class ImportConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function prefix($prefix, bool $trailingSlashOnRoot = true)
|
||||
final public function prefix($prefix, bool $trailingSlashOnRoot = true): self
|
||||
{
|
||||
if (!\is_array($prefix)) {
|
||||
$this->route->addPrefix($prefix);
|
||||
@@ -84,7 +84,7 @@ class ImportConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function namePrefix(string $namePrefix)
|
||||
final public function namePrefix(string $namePrefix): self
|
||||
{
|
||||
$this->route->addNamePrefix($namePrefix);
|
||||
|
||||
|
||||
@@ -34,12 +34,13 @@ class RoutingConfigurator
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImportConfigurator
|
||||
* @param string|string[]|null $exclude Glob patterns to exclude from the import
|
||||
*/
|
||||
final public function import($resource, $type = null, $ignoreErrors = false)
|
||||
final public function import($resource, string $type = null, bool $ignoreErrors = false, $exclude = null): ImportConfigurator
|
||||
{
|
||||
$this->loader->setCurrentDir(\dirname($this->path));
|
||||
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
|
||||
|
||||
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file, $exclude) ?: [];
|
||||
if (!\is_array($imported)) {
|
||||
return new ImportConfigurator($this->collection, $imported);
|
||||
}
|
||||
@@ -52,10 +53,7 @@ class RoutingConfigurator
|
||||
return new ImportConfigurator($this->collection, $mergedCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CollectionConfigurator
|
||||
*/
|
||||
final public function collection($name = '')
|
||||
final public function collection(string $name = ''): CollectionConfigurator
|
||||
{
|
||||
return new CollectionConfigurator($this->collection, $name);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ trait AddTrait
|
||||
return $this->add($name, $path);
|
||||
}
|
||||
|
||||
private function createRoute($path): Route
|
||||
private function createRoute(string $path): Route
|
||||
{
|
||||
return new Route($path);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function defaults(array $defaults)
|
||||
final public function defaults(array $defaults): self
|
||||
{
|
||||
$this->route->addDefaults($defaults);
|
||||
|
||||
@@ -38,7 +38,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function requirements(array $requirements)
|
||||
final public function requirements(array $requirements): self
|
||||
{
|
||||
$this->route->addRequirements($requirements);
|
||||
|
||||
@@ -50,7 +50,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function options(array $options)
|
||||
final public function options(array $options): self
|
||||
{
|
||||
$this->route->addOptions($options);
|
||||
|
||||
@@ -62,7 +62,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function utf8(bool $utf8 = true)
|
||||
final public function utf8(bool $utf8 = true): self
|
||||
{
|
||||
$this->route->addOptions(['utf8' => $utf8]);
|
||||
|
||||
@@ -74,7 +74,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function condition(string $condition)
|
||||
final public function condition(string $condition): self
|
||||
{
|
||||
$this->route->setCondition($condition);
|
||||
|
||||
@@ -86,7 +86,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function host(string $pattern)
|
||||
final public function host(string $pattern): self
|
||||
{
|
||||
$this->route->setHost($pattern);
|
||||
|
||||
@@ -101,7 +101,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function schemes(array $schemes)
|
||||
final public function schemes(array $schemes): self
|
||||
{
|
||||
$this->route->setSchemes($schemes);
|
||||
|
||||
@@ -116,7 +116,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function methods(array $methods)
|
||||
final public function methods(array $methods): self
|
||||
{
|
||||
$this->route->setMethods($methods);
|
||||
|
||||
@@ -130,7 +130,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function controller($controller)
|
||||
final public function controller($controller): self
|
||||
{
|
||||
$this->route->addDefaults(['_controller' => $controller]);
|
||||
|
||||
@@ -142,7 +142,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function locale(string $locale)
|
||||
final public function locale(string $locale): self
|
||||
{
|
||||
$this->route->addDefaults(['_locale' => $locale]);
|
||||
|
||||
@@ -154,7 +154,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function format(string $format)
|
||||
final public function format(string $format): self
|
||||
{
|
||||
$this->route->addDefaults(['_format' => $format]);
|
||||
|
||||
|
||||
45
vendor/symfony/routing/Loader/ContainerLoader.php
vendored
Normal file
45
vendor/symfony/routing/Loader/ContainerLoader.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* A route loader that executes a service from a PSR-11 container to load the routes.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@knpuniversity.com>
|
||||
*/
|
||||
class ContainerLoader extends ObjectLoader
|
||||
{
|
||||
private $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return 'service' === $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getObject(string $id)
|
||||
{
|
||||
return $this->container->get($id);
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,17 @@
|
||||
namespace Symfony\Component\Routing\Loader\DependencyInjection;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\Routing\Loader\ContainerLoader;
|
||||
use Symfony\Component\Routing\Loader\ObjectRouteLoader;
|
||||
|
||||
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ServiceRouterLoader::class, ContainerLoader::class), E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A route loader that executes a service to load the routes.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@knpuniversity.com>
|
||||
*
|
||||
* @deprecated since Symfony 4.4, use Symfony\Component\Routing\Loader\ContainerLoader instead.
|
||||
*/
|
||||
class ServiceRouterLoader extends ObjectRouteLoader
|
||||
{
|
||||
|
||||
84
vendor/symfony/routing/Loader/ObjectLoader.php
vendored
Normal file
84
vendor/symfony/routing/Loader/ObjectLoader.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\Loader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* A route loader that calls a method on an object to load the routes.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@knpuniversity.com>
|
||||
*/
|
||||
abstract class ObjectLoader extends Loader
|
||||
{
|
||||
/**
|
||||
* Returns the object that the method will be called on to load routes.
|
||||
*
|
||||
* For example, if your application uses a service container,
|
||||
* the $id may be a service id.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
abstract protected function getObject(string $id);
|
||||
|
||||
/**
|
||||
* Calls the object method that will load the routes.
|
||||
*
|
||||
* @param string $resource object_id::method
|
||||
* @param string|null $type The resource type
|
||||
*
|
||||
* @return RouteCollection
|
||||
*/
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
if (!preg_match('/^[^\:]+(?:::(?:[^\:]+))?$/', $resource)) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the %s route loader: use the format "object_id::method" or "object_id" if your object class has an "__invoke" method.', $resource, \is_string($type) ? '"'.$type.'"' : 'object'));
|
||||
}
|
||||
|
||||
$parts = explode('::', $resource);
|
||||
$method = $parts[1] ?? '__invoke';
|
||||
|
||||
$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)));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
$routeCollection = $loaderObject->$method($this);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
// make the object file tracked so that if it changes, the cache rebuilds
|
||||
$this->addClassResource(new \ReflectionClass($loaderObject), $routeCollection);
|
||||
|
||||
return $routeCollection;
|
||||
}
|
||||
|
||||
private function addClassResource(\ReflectionClass $class, RouteCollection $collection)
|
||||
{
|
||||
do {
|
||||
if (is_file($class->getFileName())) {
|
||||
$collection->addResource(new FileResource($class->getFileName()));
|
||||
}
|
||||
} while ($class = $class->getParentClass());
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,18 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\Loader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ObjectRouteLoader::class, ObjectLoader::class), E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A route loader that calls a method on an object to load the routes.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@knpuniversity.com>
|
||||
*
|
||||
* @deprecated since Symfony 4.4, use ObjectLoader instead.
|
||||
*/
|
||||
abstract class ObjectRouteLoader extends Loader
|
||||
abstract class ObjectRouteLoader extends ObjectLoader
|
||||
{
|
||||
/**
|
||||
* Returns the object that the method will be called on to load routes.
|
||||
@@ -53,32 +55,7 @@ abstract class ObjectRouteLoader extends Loader
|
||||
@trigger_error(sprintf('Referencing service route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$parts = explode('::', $resource);
|
||||
$serviceString = $parts[0];
|
||||
$method = $parts[1] ?? '__invoke';
|
||||
|
||||
$loaderObject = $this->getServiceObject($serviceString);
|
||||
|
||||
if (!\is_object($loaderObject)) {
|
||||
throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
|
||||
}
|
||||
|
||||
if (!\is_callable([$loaderObject, $method])) {
|
||||
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
|
||||
}
|
||||
|
||||
$routeCollection = $loaderObject->$method($this);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
// make the service file tracked so that if it changes, the cache rebuilds
|
||||
$this->addClassResource(new \ReflectionClass($loaderObject), $routeCollection);
|
||||
|
||||
return $routeCollection;
|
||||
return parent::load($resource, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,12 +66,11 @@ abstract class ObjectRouteLoader extends Loader
|
||||
return 'service' === $type;
|
||||
}
|
||||
|
||||
private function addClassResource(\ReflectionClass $class, RouteCollection $collection)
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getObject(string $id)
|
||||
{
|
||||
do {
|
||||
if (is_file($class->getFileName())) {
|
||||
$collection->addResource(new FileResource($class->getFileName()));
|
||||
}
|
||||
} while ($class = $class->getParentClass());
|
||||
return $this->getServiceObject($id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class PhpFileLoader extends FileLoader
|
||||
|
||||
// the closure forbids access to the private scope in the included file
|
||||
$loader = $this;
|
||||
$load = \Closure::bind(function ($file) use ($loader) {
|
||||
$load = \Closure::bind(static function ($file) use ($loader) {
|
||||
return include $file;
|
||||
}, null, ProtectedPhpFileLoader::class);
|
||||
|
||||
|
||||
58
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
58
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
@@ -63,10 +63,9 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses a node from a loaded XML file.
|
||||
*
|
||||
* @param RouteCollection $collection Collection to associate with the node
|
||||
* @param \DOMElement $node Element to parse
|
||||
* @param string $path Full path of the XML file being processed
|
||||
* @param string $file Loaded file name
|
||||
* @param \DOMElement $node Element to parse
|
||||
* @param string $path Full path of the XML file being processed
|
||||
* @param string $file Loaded file name
|
||||
*
|
||||
* @throws \InvalidArgumentException When the XML is invalid
|
||||
*/
|
||||
@@ -99,9 +98,8 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses a route and adds it to the RouteCollection.
|
||||
*
|
||||
* @param RouteCollection $collection RouteCollection instance
|
||||
* @param \DOMElement $node Element to parse that represents a Route
|
||||
* @param string $path Full path of the XML file being processed
|
||||
* @param \DOMElement $node Element to parse that represents a Route
|
||||
* @param string $path Full path of the XML file being processed
|
||||
*
|
||||
* @throws \InvalidArgumentException When the XML is invalid
|
||||
*/
|
||||
@@ -140,10 +138,9 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses an import and adds the routes in the resource to the RouteCollection.
|
||||
*
|
||||
* @param RouteCollection $collection RouteCollection instance
|
||||
* @param \DOMElement $node Element to parse that represents a Route
|
||||
* @param string $path Full path of the XML file being processed
|
||||
* @param string $file Loaded file name
|
||||
* @param \DOMElement $node Element to parse that represents a Route
|
||||
* @param string $path Full path of the XML file being processed
|
||||
* @param string $file Loaded file name
|
||||
*
|
||||
* @throws \InvalidArgumentException When the XML is invalid
|
||||
*/
|
||||
@@ -166,10 +163,24 @@ class XmlFileLoader extends FileLoader
|
||||
throw new \InvalidArgumentException(sprintf('The <route> element in file "%s" must not have both a "prefix" attribute and <prefix> child nodes.', $path));
|
||||
}
|
||||
|
||||
$exclude = [];
|
||||
foreach ($node->childNodes as $child) {
|
||||
if ($child instanceof \DOMElement && $child->localName === $exclude && self::NAMESPACE_URI === $child->namespaceURI) {
|
||||
$exclude[] = $child->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($node->hasAttribute('exclude')) {
|
||||
if ($exclude) {
|
||||
throw new \InvalidArgumentException('You cannot use both the attribute "exclude" and <exclude> tags at the same time.');
|
||||
}
|
||||
$exclude = [$node->getAttribute('exclude')];
|
||||
}
|
||||
|
||||
$this->setCurrentDir(\dirname($path));
|
||||
|
||||
/** @var RouteCollection[] $imported */
|
||||
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
|
||||
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file, $exclude) ?: [];
|
||||
|
||||
if (!\is_array($imported)) {
|
||||
$imported = [$imported];
|
||||
@@ -253,14 +264,9 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses the config elements (default, requirement, option).
|
||||
*
|
||||
* @param \DOMElement $node Element to parse that contains the configs
|
||||
* @param string $path Full path of the XML file being processed
|
||||
*
|
||||
* @return array An array with the defaults as first item, requirements as second and options as third
|
||||
*
|
||||
* @throws \InvalidArgumentException When the XML is invalid
|
||||
*/
|
||||
private function parseConfigs(\DOMElement $node, $path)
|
||||
private function parseConfigs(\DOMElement $node, string $path): array
|
||||
{
|
||||
$defaults = [];
|
||||
$requirements = [];
|
||||
@@ -329,15 +335,12 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses the "default" elements.
|
||||
*
|
||||
* @param \DOMElement $element The "default" element to parse
|
||||
* @param string $path Full path of the XML file being processed
|
||||
*
|
||||
* @return array|bool|float|int|string|null The parsed value of the "default" element
|
||||
*/
|
||||
private function parseDefaultsConfig(\DOMElement $element, $path)
|
||||
private function parseDefaultsConfig(\DOMElement $element, string $path)
|
||||
{
|
||||
if ($this->isElementValueNull($element)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check for existing element nodes in the default element. There can
|
||||
@@ -364,17 +367,14 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Recursively parses the value of a "default" element.
|
||||
*
|
||||
* @param \DOMElement $node The node value
|
||||
* @param string $path Full path of the XML file being processed
|
||||
*
|
||||
* @return array|bool|float|int|string The parsed value
|
||||
*
|
||||
* @throws \InvalidArgumentException when the XML is invalid
|
||||
*/
|
||||
private function parseDefaultNode(\DOMElement $node, $path)
|
||||
private function parseDefaultNode(\DOMElement $node, string $path)
|
||||
{
|
||||
if ($this->isElementValueNull($node)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($node->localName) {
|
||||
@@ -423,7 +423,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
}
|
||||
|
||||
private function isElementValueNull(\DOMElement $element)
|
||||
private function isElementValueNull(\DOMElement $element): bool
|
||||
{
|
||||
$namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance';
|
||||
|
||||
|
||||
19
vendor/symfony/routing/Loader/YamlFileLoader.php
vendored
19
vendor/symfony/routing/Loader/YamlFileLoader.php
vendored
@@ -28,7 +28,7 @@ use Symfony\Component\Yaml\Yaml;
|
||||
class YamlFileLoader extends FileLoader
|
||||
{
|
||||
private static $availableKeys = [
|
||||
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', 'name_prefix', 'trailing_slash_on_root', 'locale', 'format', 'utf8',
|
||||
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', 'name_prefix', 'trailing_slash_on_root', 'locale', 'format', 'utf8', 'exclude',
|
||||
];
|
||||
private $yamlParser;
|
||||
|
||||
@@ -101,10 +101,9 @@ class YamlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses a route and adds it to the RouteCollection.
|
||||
*
|
||||
* @param RouteCollection $collection A RouteCollection instance
|
||||
* @param string $name Route name
|
||||
* @param array $config Route definition
|
||||
* @param string $path Full path of the YAML file being processed
|
||||
* @param string $name Route name
|
||||
* @param array $config Route definition
|
||||
* @param string $path Full path of the YAML file being processed
|
||||
*/
|
||||
protected function parseRoute(RouteCollection $collection, $name, array $config, $path)
|
||||
{
|
||||
@@ -154,10 +153,9 @@ class YamlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses an import and adds the routes in the resource to the RouteCollection.
|
||||
*
|
||||
* @param RouteCollection $collection A RouteCollection instance
|
||||
* @param array $config Route definition
|
||||
* @param string $path Full path of the YAML file being processed
|
||||
* @param string $file Loaded file name
|
||||
* @param array $config Route definition
|
||||
* @param string $path Full path of the YAML file being processed
|
||||
* @param string $file Loaded file name
|
||||
*/
|
||||
protected function parseImport(RouteCollection $collection, array $config, $path, $file)
|
||||
{
|
||||
@@ -171,6 +169,7 @@ class YamlFileLoader extends FileLoader
|
||||
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
|
||||
$methods = isset($config['methods']) ? $config['methods'] : null;
|
||||
$trailingSlashOnRoot = $config['trailing_slash_on_root'] ?? true;
|
||||
$exclude = $config['exclude'] ?? null;
|
||||
|
||||
if (isset($config['controller'])) {
|
||||
$defaults['_controller'] = $config['controller'];
|
||||
@@ -187,7 +186,7 @@ class YamlFileLoader extends FileLoader
|
||||
|
||||
$this->setCurrentDir(\dirname($path));
|
||||
|
||||
$imported = $this->import($config['resource'], $type, false, $file);
|
||||
$imported = $this->import($config['resource'], $type, false, $file, $exclude) ?: [];
|
||||
|
||||
if (!\is_array($imported)) {
|
||||
$imported = [$imported];
|
||||
|
||||
@@ -61,9 +61,11 @@
|
||||
<xsd:sequence maxOccurs="unbounded" minOccurs="0">
|
||||
<xsd:group ref="configs" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="prefix" type="localized-path" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="exclude" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="resource" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="exclude" type="xsd:string" />
|
||||
<xsd:attribute name="prefix" type="xsd:string" />
|
||||
<xsd:attribute name="name-prefix" type="xsd:string" />
|
||||
<xsd:attribute name="host" type="xsd:string" />
|
||||
|
||||
Reference in New Issue
Block a user