ActionsHelper.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Templating\Helper;
  11. use Symfony\Component\HttpKernel\Controller\ControllerReference;
  12. use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
  13. use Symfony\Component\Templating\Helper\Helper;
  14. /**
  15. * ActionsHelper manages action inclusions.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. class ActionsHelper extends Helper
  20. {
  21. private $handler;
  22. public function __construct(FragmentHandler $handler)
  23. {
  24. $this->handler = $handler;
  25. }
  26. /**
  27. * Returns the fragment content for a given URI.
  28. *
  29. * @param string $uri A URI
  30. * @param array $options An array of options
  31. *
  32. * @return string The fragment content
  33. *
  34. * @see FragmentHandler::render()
  35. */
  36. public function render($uri, array $options = array())
  37. {
  38. $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
  39. unset($options['strategy']);
  40. return $this->handler->render($uri, $strategy, $options);
  41. }
  42. public function controller($controller, $attributes = array(), $query = array())
  43. {
  44. return new ControllerReference($controller, $attributes, $query);
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function getName()
  50. {
  51. return 'actions';
  52. }
  53. }