InternalController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\Controller;
  11. use Symfony\Component\DependencyInjection\ContainerAware;
  12. use Symfony\Component\HttpFoundation\Response;
  13. /**
  14. * InternalController.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class InternalController extends ContainerAware
  19. {
  20. /**
  21. * Forwards to the given controller with the given path.
  22. *
  23. * @param string $path The path
  24. * @param string $controller The controller name
  25. *
  26. * @return Response A Response instance
  27. */
  28. public function indexAction($path, $controller)
  29. {
  30. $request = $this->container->get('request');
  31. $attributes = $request->attributes;
  32. $attributes->remove('path');
  33. $attributes->remove('controller');
  34. if ('none' !== $path) {
  35. parse_str($path, $tmp);
  36. $attributes->add($tmp);
  37. }
  38. return $this->container->get('http_kernel')->forward($controller, $attributes->all(), $request->query->all());
  39. }
  40. }