2010-02-17 13:55:05 +00:00
|
|
|
<?php
|
|
|
|
|
2010-07-09 09:05:26 +01:00
|
|
|
namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
|
2010-02-17 13:55:05 +00:00
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\Templating\Helper\Helper;
|
|
|
|
use Symfony\Component\OutputEscaper\Escaper;
|
2010-07-22 18:57:45 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver;
|
2010-02-17 13:55:05 +00:00
|
|
|
|
|
|
|
/*
|
2010-04-07 01:51:29 +01:00
|
|
|
* This file is part of the Symfony framework.
|
2010-02-17 13:55:05 +00:00
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-07 01:51:29 +01:00
|
|
|
* ActionsHelper.
|
2010-02-17 13:55:05 +00:00
|
|
|
*
|
|
|
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*/
|
|
|
|
class ActionsHelper extends Helper
|
|
|
|
{
|
2010-07-22 18:57:45 +01:00
|
|
|
protected $resolver;
|
2010-05-06 12:25:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param Constructor $container A ContainerInterface instance
|
|
|
|
*/
|
2010-07-22 18:57:45 +01:00
|
|
|
public function __construct(ControllerResolver $resolver)
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
2010-07-22 18:57:45 +01:00
|
|
|
$this->resolver = $resolver;
|
2010-05-06 12:25:53 +01:00
|
|
|
}
|
|
|
|
|
2010-05-13 07:29:04 +01:00
|
|
|
/**
|
|
|
|
* Outputs the Response content for a given controller.
|
|
|
|
*
|
2010-05-14 10:22:20 +01:00
|
|
|
* @param string $controller A controller name to execute (a string like BlogBundle:Post:index), or a relative URI
|
2010-05-13 19:23:23 +01:00
|
|
|
* @param array $options An array of options
|
2010-05-13 07:29:04 +01:00
|
|
|
*
|
|
|
|
* @see render()
|
|
|
|
*/
|
2010-05-14 10:22:20 +01:00
|
|
|
public function output($controller, array $options = array())
|
2010-05-13 19:23:23 +01:00
|
|
|
{
|
2010-05-14 10:22:20 +01:00
|
|
|
echo $this->render($controller, $options);
|
2010-05-13 19:23:23 +01:00
|
|
|
}
|
2010-05-06 12:25:53 +01:00
|
|
|
|
2010-05-13 07:29:04 +01:00
|
|
|
/**
|
2010-05-14 10:22:20 +01:00
|
|
|
* Returns the Response content for a given controller or URI.
|
2010-05-13 07:29:04 +01:00
|
|
|
*
|
2010-05-14 10:22:20 +01:00
|
|
|
* @param string $controller A controller name to execute (a string like BlogBundle:Post:index), or a relative URI
|
2010-08-30 08:15:54 +01:00
|
|
|
* @param array $attributes An array of request attributes
|
2010-05-13 19:23:23 +01:00
|
|
|
* @param array $options An array of options
|
2010-05-18 12:05:03 +01:00
|
|
|
*
|
2010-07-22 18:57:45 +01:00
|
|
|
* @see Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver::render()
|
2010-05-13 07:29:04 +01:00
|
|
|
*/
|
2010-08-30 08:15:54 +01:00
|
|
|
public function render($controller, array $attributes = array(), array $options = array())
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
2010-08-30 08:15:54 +01:00
|
|
|
$options['attributes'] = Escaper::unescape($attributes);
|
2010-05-13 19:23:23 +01:00
|
|
|
|
2010-05-18 12:05:03 +01:00
|
|
|
if (isset($options['query']))
|
|
|
|
{
|
|
|
|
$options['query'] = Escaper::unescape($options['query']);
|
|
|
|
}
|
2010-05-13 19:23:23 +01:00
|
|
|
|
2010-07-22 18:57:45 +01:00
|
|
|
return $this->resolver->render($controller, $options);
|
2010-05-06 12:25:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the canonical name of this helper.
|
|
|
|
*
|
|
|
|
* @return string The canonical name
|
|
|
|
*/
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'actions';
|
|
|
|
}
|
2010-02-17 13:55:05 +00:00
|
|
|
}
|