vendor/symfony/http-kernel/Controller/ArgumentResolver/TraceableValueResolver.php line 60

  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
  13. use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
  14. use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
  15. use Symfony\Component\Stopwatch\Stopwatch;
  16. /**
  17.  * Provides timing information via the stopwatch.
  18.  *
  19.  * @author Iltar van der Berg <kjarli@gmail.com>
  20.  */
  21. final class TraceableValueResolver implements ArgumentValueResolverInterfaceValueResolverInterface
  22. {
  23.     private ArgumentValueResolverInterface|ValueResolverInterface $inner;
  24.     private Stopwatch $stopwatch;
  25.     public function __construct(ArgumentValueResolverInterface|ValueResolverInterface $innerStopwatch $stopwatch)
  26.     {
  27.         $this->inner $inner;
  28.         $this->stopwatch $stopwatch;
  29.     }
  30.     /**
  31.      * @deprecated since Symfony 6.2, use resolve() instead
  32.      */
  33.     public function supports(Request $requestArgumentMetadata $argument): bool
  34.     {
  35.         if ($this->inner instanceof ValueResolverInterface) {
  36.             return true;
  37.         }
  38.         $method \get_class($this->inner).'::'.__FUNCTION__;
  39.         $this->stopwatch->start($method'controller.argument_value_resolver');
  40.         $return $this->inner->supports($request$argument);
  41.         $this->stopwatch->stop($method);
  42.         return $return;
  43.     }
  44.     public function resolve(Request $requestArgumentMetadata $argument): iterable
  45.     {
  46.         $method \get_class($this->inner).'::'.__FUNCTION__;
  47.         $this->stopwatch->start($method'controller.argument_value_resolver');
  48.         yield from $this->inner->resolve($request$argument);
  49.         $this->stopwatch->stop($method);
  50.     }
  51. }