TraceableControllerResolver.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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;
  11. use Symfony\Component\Stopwatch\Stopwatch;
  12. use Symfony\Component\HttpFoundation\Request;
  13. /**
  14. * TraceableControllerResolver.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class TraceableControllerResolver implements ControllerResolverInterface
  19. {
  20. private $resolver;
  21. private $stopwatch;
  22. /**
  23. * Constructor.
  24. *
  25. * @param ControllerResolverInterface $resolver A ControllerResolverInterface instance
  26. * @param Stopwatch $stopwatch A Stopwatch instance
  27. */
  28. public function __construct(ControllerResolverInterface $resolver, Stopwatch $stopwatch)
  29. {
  30. $this->resolver = $resolver;
  31. $this->stopwatch = $stopwatch;
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function getController(Request $request)
  37. {
  38. $e = $this->stopwatch->start('controller.get_callable');
  39. $ret = $this->resolver->getController($request);
  40. $e->stop();
  41. return $ret;
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getArguments(Request $request, $controller)
  47. {
  48. $e = $this->stopwatch->start('controller.get_arguments');
  49. $ret = $this->resolver->getArguments($request, $controller);
  50. $e->stop();
  51. return $ret;
  52. }
  53. }