comparison vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php @ 0:4c8ae668cc8c

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