annotate vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php @ 8:50b0d041100e

Further files for download
author Chris Cannam
date Mon, 05 Feb 2018 10:56:40 +0000
parents 4c8ae668cc8c
children 1fec387a4317
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\HttpKernel\Controller;
Chris@0 13
Chris@0 14 use Symfony\Component\Stopwatch\Stopwatch;
Chris@0 15 use Symfony\Component\HttpFoundation\Request;
Chris@0 16
Chris@0 17 /**
Chris@0 18 * TraceableControllerResolver.
Chris@0 19 *
Chris@0 20 * @author Fabien Potencier <fabien@symfony.com>
Chris@0 21 */
Chris@0 22 class TraceableControllerResolver implements ControllerResolverInterface, ArgumentResolverInterface
Chris@0 23 {
Chris@0 24 private $resolver;
Chris@0 25 private $stopwatch;
Chris@0 26 private $argumentResolver;
Chris@0 27
Chris@0 28 /**
Chris@0 29 * Constructor.
Chris@0 30 *
Chris@0 31 * @param ControllerResolverInterface $resolver A ControllerResolverInterface instance
Chris@0 32 * @param Stopwatch $stopwatch A Stopwatch instance
Chris@0 33 * @param ArgumentResolverInterface $argumentResolver Only required for BC
Chris@0 34 */
Chris@0 35 public function __construct(ControllerResolverInterface $resolver, Stopwatch $stopwatch, ArgumentResolverInterface $argumentResolver = null)
Chris@0 36 {
Chris@0 37 $this->resolver = $resolver;
Chris@0 38 $this->stopwatch = $stopwatch;
Chris@0 39 $this->argumentResolver = $argumentResolver;
Chris@0 40
Chris@0 41 // BC
Chris@0 42 if (null === $this->argumentResolver) {
Chris@0 43 $this->argumentResolver = $resolver;
Chris@0 44 }
Chris@0 45
Chris@0 46 if (!$this->argumentResolver instanceof TraceableArgumentResolver) {
Chris@0 47 $this->argumentResolver = new TraceableArgumentResolver($this->argumentResolver, $this->stopwatch);
Chris@0 48 }
Chris@0 49 }
Chris@0 50
Chris@0 51 /**
Chris@0 52 * {@inheritdoc}
Chris@0 53 */
Chris@0 54 public function getController(Request $request)
Chris@0 55 {
Chris@0 56 $e = $this->stopwatch->start('controller.get_callable');
Chris@0 57
Chris@0 58 $ret = $this->resolver->getController($request);
Chris@0 59
Chris@0 60 $e->stop();
Chris@0 61
Chris@0 62 return $ret;
Chris@0 63 }
Chris@0 64
Chris@0 65 /**
Chris@0 66 * {@inheritdoc}
Chris@0 67 *
Chris@0 68 * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0.
Chris@0 69 */
Chris@0 70 public function getArguments(Request $request, $controller)
Chris@0 71 {
Chris@0 72 @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);
Chris@0 73
Chris@0 74 $ret = $this->argumentResolver->getArguments($request, $controller);
Chris@0 75
Chris@0 76 return $ret;
Chris@0 77 }
Chris@0 78 }