update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
10
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver.php
vendored
Executable file → Normal file
10
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver.php
vendored
Executable file → Normal file
|
|
@ -56,7 +56,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
|||
$resolved = $resolver->resolve($request, $metadata);
|
||||
|
||||
if (!$resolved instanceof \Generator) {
|
||||
throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', get_class($resolver)));
|
||||
throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', \get_class($resolver)));
|
||||
}
|
||||
|
||||
foreach ($resolved as $append) {
|
||||
|
|
@ -69,10 +69,10 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
|||
|
||||
$representative = $controller;
|
||||
|
||||
if (is_array($representative)) {
|
||||
$representative = sprintf('%s::%s()', get_class($representative[0]), $representative[1]);
|
||||
} elseif (is_object($representative)) {
|
||||
$representative = get_class($representative);
|
||||
if (\is_array($representative)) {
|
||||
$representative = sprintf('%s::%s()', \get_class($representative[0]), $representative[1]);
|
||||
} elseif (\is_object($representative)) {
|
||||
$representative = \get_class($representative);
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.', $representative, $metadata->getName()));
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/DefaultValueResolver.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/DefaultValueResolver.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestValueResolver.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestValueResolver.php
vendored
Executable file → Normal file
24
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php
vendored
Executable file → Normal file
24
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php
vendored
Executable file → Normal file
|
|
@ -35,7 +35,19 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
|
|||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
{
|
||||
return is_string($controller = $request->attributes->get('_controller')) && $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
|
||||
$controller = $request->attributes->get('_controller');
|
||||
|
||||
if (\is_array($controller) && \is_callable($controller, true) && \is_string($controller[0])) {
|
||||
$controller = $controller[0].'::'.$controller[1];
|
||||
} elseif (!\is_string($controller) || '' === $controller) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('\\' === $controller[0]) {
|
||||
$controller = ltrim($controller, '\\');
|
||||
}
|
||||
|
||||
return $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -43,6 +55,14 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
|
|||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
{
|
||||
yield $this->container->get($request->attributes->get('_controller'))->get($argument->getName());
|
||||
if (\is_array($controller = $request->attributes->get('_controller'))) {
|
||||
$controller = $controller[0].'::'.$controller[1];
|
||||
}
|
||||
|
||||
if ('\\' === $controller[0]) {
|
||||
$controller = ltrim($controller, '\\');
|
||||
}
|
||||
|
||||
yield $this->container->get($controller)->get($argument->getName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/VariadicValueResolver.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolver/VariadicValueResolver.php
vendored
Executable file → Normal file
|
|
@ -37,8 +37,8 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface
|
|||
{
|
||||
$values = $request->attributes->get($argument->getName());
|
||||
|
||||
if (!is_array($values)) {
|
||||
throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), gettype($values)));
|
||||
if (!\is_array($values)) {
|
||||
throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), \gettype($values)));
|
||||
}
|
||||
|
||||
foreach ($values as $value) {
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolverInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentResolverInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentValueResolverInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-kernel/Controller/ArgumentValueResolverInterface.php
vendored
Executable file → Normal file
61
pfosten/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php
vendored
Executable file → Normal file
61
pfosten/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php
vendored
Executable file → Normal file
|
|
@ -13,6 +13,8 @@ namespace Symfony\Component\HttpKernel\Controller;
|
|||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* A controller resolver searching for a controller in a psr-11 container when using the "service:method" notation.
|
||||
|
|
@ -31,6 +33,20 @@ class ContainerControllerResolver extends ControllerResolver
|
|||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getController(Request $request)
|
||||
{
|
||||
$controller = parent::getController($request);
|
||||
|
||||
if (\is_array($controller) && isset($controller[0]) && \is_string($controller[0]) && $this->container->has($controller[0])) {
|
||||
$controller[0] = $this->instantiateController($controller[0]);
|
||||
}
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a callable for the given controller.
|
||||
*
|
||||
|
|
@ -47,19 +63,28 @@ class ContainerControllerResolver extends ControllerResolver
|
|||
return parent::createController($controller);
|
||||
}
|
||||
|
||||
$method = null;
|
||||
if (1 == substr_count($controller, ':')) {
|
||||
// controller in the "service:method" notation
|
||||
list($service, $method) = explode(':', $controller, 2);
|
||||
|
||||
return array($this->container->get($service), $method);
|
||||
list($controller, $method) = explode(':', $controller, 2);
|
||||
}
|
||||
|
||||
if ($this->container->has($controller) && method_exists($service = $this->container->get($controller), '__invoke')) {
|
||||
// invokable controller in the "service" notation
|
||||
return $service;
|
||||
if (!$this->container->has($controller)) {
|
||||
$this->throwExceptionIfControllerWasRemoved($controller);
|
||||
|
||||
throw new \LogicException(sprintf('Controller not found: service "%s" does not exist.', $controller));
|
||||
}
|
||||
|
||||
throw new \LogicException(sprintf('Unable to parse the controller name "%s".', $controller));
|
||||
$service = $this->container->get($controller);
|
||||
if (null !== $method) {
|
||||
return array($service, $method);
|
||||
}
|
||||
|
||||
if (!method_exists($service, '__invoke')) {
|
||||
throw new \LogicException(sprintf('Controller "%s" cannot be called without a method name. Did you forget an "__invoke" method?', $controller));
|
||||
}
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,6 +96,26 @@ class ContainerControllerResolver extends ControllerResolver
|
|||
return $this->container->get($class);
|
||||
}
|
||||
|
||||
return parent::instantiateController($class);
|
||||
try {
|
||||
return parent::instantiateController($class);
|
||||
} catch (\ArgumentCountError $e) {
|
||||
} catch (\ErrorException $e) {
|
||||
} catch (\TypeError $e) {
|
||||
}
|
||||
|
||||
$this->throwExceptionIfControllerWasRemoved($class, $e);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $controller
|
||||
* @param \Exception|\Throwable|null $previous
|
||||
*/
|
||||
private function throwExceptionIfControllerWasRemoved($controller, $previous = null)
|
||||
{
|
||||
if ($this->container instanceof Container && isset($this->container->getRemovedIds()[$controller])) {
|
||||
throw new \LogicException(sprintf('Controller "%s" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?', $controller), 0, $previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-kernel/Controller/ControllerReference.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-kernel/Controller/ControllerReference.php
vendored
Executable file → Normal file
|
|
@ -31,8 +31,6 @@ class ControllerReference
|
|||
public $query = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $controller The controller name
|
||||
* @param array $attributes An array of parameters to add to the Request attributes
|
||||
* @param array $query An array of parameters to add to the Request query string
|
||||
|
|
|
|||
55
pfosten/vendor/symfony/http-kernel/Controller/ControllerResolver.php
vendored
Executable file → Normal file
55
pfosten/vendor/symfony/http-kernel/Controller/ControllerResolver.php
vendored
Executable file → Normal file
|
|
@ -15,8 +15,6 @@ use Psr\Log\LoggerInterface;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* ControllerResolver.
|
||||
*
|
||||
* This implementation uses the '_controller' request attribute to determine
|
||||
* the controller to execute and uses the request attributes to determine
|
||||
* the controller method arguments.
|
||||
|
|
@ -43,11 +41,6 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
*/
|
||||
private $supportsScalarTypes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
*/
|
||||
public function __construct(LoggerInterface $logger = null)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
|
|
@ -72,29 +65,29 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
return false;
|
||||
}
|
||||
|
||||
if (is_array($controller)) {
|
||||
if (\is_array($controller)) {
|
||||
return $controller;
|
||||
}
|
||||
|
||||
if (is_object($controller)) {
|
||||
if (\is_object($controller)) {
|
||||
if (method_exists($controller, '__invoke')) {
|
||||
return $controller;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', get_class($controller), $request->getPathInfo()));
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', \get_class($controller), $request->getPathInfo()));
|
||||
}
|
||||
|
||||
if (false === strpos($controller, ':')) {
|
||||
if (method_exists($controller, '__invoke')) {
|
||||
return $this->instantiateController($controller);
|
||||
} elseif (function_exists($controller)) {
|
||||
} elseif (\function_exists($controller)) {
|
||||
return $controller;
|
||||
}
|
||||
}
|
||||
|
||||
$callable = $this->createController($controller);
|
||||
|
||||
if (!is_callable($callable)) {
|
||||
if (!\is_callable($callable)) {
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable)));
|
||||
}
|
||||
|
||||
|
|
@ -108,11 +101,11 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
*/
|
||||
public function getArguments(Request $request, $controller)
|
||||
{
|
||||
@trigger_error(sprintf('%s is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
|
||||
|
||||
if (is_array($controller)) {
|
||||
if (\is_array($controller)) {
|
||||
$r = new \ReflectionMethod($controller[0], $controller[1]);
|
||||
} elseif (is_object($controller) && !$controller instanceof \Closure) {
|
||||
} elseif (\is_object($controller) && !$controller instanceof \Closure) {
|
||||
$r = new \ReflectionObject($controller);
|
||||
$r = $r->getMethod('__invoke');
|
||||
} else {
|
||||
|
|
@ -133,13 +126,13 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
*/
|
||||
protected function doGetArguments(Request $request, $controller, array $parameters)
|
||||
{
|
||||
@trigger_error(sprintf('%s is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
|
||||
|
||||
$attributes = $request->attributes->all();
|
||||
$arguments = array();
|
||||
foreach ($parameters as $param) {
|
||||
if (array_key_exists($param->name, $attributes)) {
|
||||
if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) {
|
||||
if ($this->supportsVariadic && $param->isVariadic() && \is_array($attributes[$param->name])) {
|
||||
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
|
||||
} else {
|
||||
$arguments[] = $attributes[$param->name];
|
||||
|
|
@ -151,10 +144,10 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
} elseif ($this->supportsScalarTypes && $param->hasType() && $param->allowsNull()) {
|
||||
$arguments[] = null;
|
||||
} else {
|
||||
if (is_array($controller)) {
|
||||
$repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);
|
||||
} elseif (is_object($controller)) {
|
||||
$repr = get_class($controller);
|
||||
if (\is_array($controller)) {
|
||||
$repr = sprintf('%s::%s()', \get_class($controller[0]), $controller[1]);
|
||||
} elseif (\is_object($controller)) {
|
||||
$repr = \get_class($controller);
|
||||
} else {
|
||||
$repr = $controller;
|
||||
}
|
||||
|
|
@ -204,7 +197,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
|
||||
private function getControllerError($callable)
|
||||
{
|
||||
if (is_string($callable)) {
|
||||
if (\is_string($callable)) {
|
||||
if (false !== strpos($callable, '::')) {
|
||||
$callable = explode('::', $callable);
|
||||
}
|
||||
|
|
@ -213,26 +206,26 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
return sprintf('Class "%s" does not have a method "__invoke".', $callable);
|
||||
}
|
||||
|
||||
if (!function_exists($callable)) {
|
||||
if (!\function_exists($callable)) {
|
||||
return sprintf('Function "%s" does not exist.', $callable);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($callable)) {
|
||||
return sprintf('Invalid type for controller given, expected string or array, got "%s".', gettype($callable));
|
||||
if (!\is_array($callable)) {
|
||||
return sprintf('Invalid type for controller given, expected string or array, got "%s".', \gettype($callable));
|
||||
}
|
||||
|
||||
if (2 !== count($callable)) {
|
||||
return sprintf('Invalid format for controller, expected array(controller, method) or controller::method.');
|
||||
if (2 !== \count($callable)) {
|
||||
return 'Invalid format for controller, expected array(controller, method) or controller::method.';
|
||||
}
|
||||
|
||||
list($controller, $method) = $callable;
|
||||
|
||||
if (is_string($controller) && !class_exists($controller)) {
|
||||
if (\is_string($controller) && !class_exists($controller)) {
|
||||
return sprintf('Class "%s" does not exist.', $controller);
|
||||
}
|
||||
|
||||
$className = is_object($controller) ? get_class($controller) : $controller;
|
||||
$className = \is_object($controller) ? \get_class($controller) : $controller;
|
||||
|
||||
if (method_exists($controller, $method)) {
|
||||
return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className);
|
||||
|
|
@ -245,7 +238,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
foreach ($collection as $item) {
|
||||
$lev = levenshtein($method, $item);
|
||||
|
||||
if ($lev <= strlen($method) / 3 || false !== strpos($item, $method)) {
|
||||
if ($lev <= \strlen($method) / 3 || false !== strpos($item, $method)) {
|
||||
$alternatives[] = $item;
|
||||
}
|
||||
}
|
||||
|
|
@ -254,7 +247,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||
|
||||
$message = sprintf('Expected method "%s" on class "%s"', $method, $className);
|
||||
|
||||
if (count($alternatives) > 0) {
|
||||
if (\count($alternatives) > 0) {
|
||||
$message .= sprintf(', did you mean "%s"?', implode('", "', $alternatives));
|
||||
} else {
|
||||
$message .= sprintf('. Available methods: "%s".', implode('", "', $collection));
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-kernel/Controller/ControllerResolverInterface.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-kernel/Controller/ControllerResolverInterface.php
vendored
Executable file → Normal file
|
|
@ -34,8 +34,6 @@ interface ControllerResolverInterface
|
|||
* The resolver must only throw an exception when it should be able to load
|
||||
* controller but cannot because of some errors made by the developer.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
*
|
||||
* @return callable|false A PHP callable representing the Controller,
|
||||
* or false if this resolver is not able to determine the controller
|
||||
*
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-kernel/Controller/TraceableArgumentResolver.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-kernel/Controller/TraceableArgumentResolver.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpKernel\Controller;
|
||||
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
|
|
|
|||
13
pfosten/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php
vendored
Executable file → Normal file
13
pfosten/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php
vendored
Executable file → Normal file
|
|
@ -11,12 +11,10 @@
|
|||
|
||||
namespace Symfony\Component\HttpKernel\Controller;
|
||||
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
|
||||
/**
|
||||
* TraceableControllerResolver.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class TraceableControllerResolver implements ControllerResolverInterface, ArgumentResolverInterface
|
||||
|
|
@ -25,13 +23,6 @@ class TraceableControllerResolver implements ControllerResolverInterface, Argume
|
|||
private $stopwatch;
|
||||
private $argumentResolver;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ControllerResolverInterface $resolver A ControllerResolverInterface instance
|
||||
* @param Stopwatch $stopwatch A Stopwatch instance
|
||||
* @param ArgumentResolverInterface $argumentResolver Only required for BC
|
||||
*/
|
||||
public function __construct(ControllerResolverInterface $resolver, Stopwatch $stopwatch, ArgumentResolverInterface $argumentResolver = null)
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
|
|
@ -69,7 +60,7 @@ class TraceableControllerResolver implements ControllerResolverInterface, Argume
|
|||
*/
|
||||
public function getArguments(Request $request, $controller)
|
||||
{
|
||||
@trigger_error(sprintf('The %s method is deprecated as of 3.1 and will be removed in 4.0. Please use the %s instead.', __METHOD__, TraceableArgumentResolver::class), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Please use the %s instead.', __METHOD__, TraceableArgumentResolver::class), E_USER_DEPRECATED);
|
||||
|
||||
$ret = $this->argumentResolver->getArguments($request, $controller);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue