f8de31cf078c1b4b66baad7304c22f9935ce9558
[yaffs-website] / vendor / symfony / http-kernel / Controller / TraceableControllerResolver.php
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
23 {
24     private $resolver;
25     private $stopwatch;
26
27     /**
28      * Constructor.
29      *
30      * @param ControllerResolverInterface $resolver  A ControllerResolverInterface instance
31      * @param Stopwatch                   $stopwatch A Stopwatch instance
32      */
33     public function __construct(ControllerResolverInterface $resolver, Stopwatch $stopwatch)
34     {
35         $this->resolver = $resolver;
36         $this->stopwatch = $stopwatch;
37     }
38
39     /**
40      * {@inheritdoc}
41      */
42     public function getController(Request $request)
43     {
44         $e = $this->stopwatch->start('controller.get_callable');
45
46         $ret = $this->resolver->getController($request);
47
48         $e->stop();
49
50         return $ret;
51     }
52
53     /**
54      * {@inheritdoc}
55      */
56     public function getArguments(Request $request, $controller)
57     {
58         $e = $this->stopwatch->start('controller.get_arguments');
59
60         $ret = $this->resolver->getArguments($request, $controller);
61
62         $e->stop();
63
64         return $ret;
65     }
66 }