RouterDataCollector.php 1009 B

123456789101112131415161718192021222324252627282930313233343536373839
  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\Bundle\FrameworkBundle\DataCollector;
  11. use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpKernel\DataCollector\RouterDataCollector as BaseRouterDataCollector;
  14. /**
  15. * RouterDataCollector.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. *
  19. * @final
  20. */
  21. class RouterDataCollector extends BaseRouterDataCollector
  22. {
  23. public function guessRoute(Request $request, $controller)
  24. {
  25. if (\is_array($controller)) {
  26. $controller = $controller[0];
  27. }
  28. if ($controller instanceof RedirectController) {
  29. return $request->attributes->get('_route');
  30. }
  31. return parent::guessRoute($request, $controller);
  32. }
  33. }