2010-02-17 13:55:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Symfony\Framework\WebBundle\Helper;
|
|
|
|
|
|
|
|
use Symfony\Components\Templating\Helper\Helper;
|
|
|
|
use Symfony\Components\OutputEscaper\Escaper;
|
2010-05-18 12:05:03 +01:00
|
|
|
use Symfony\Framework\WebBundle\Controller\ControllerManager;
|
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
|
|
|
*
|
2010-04-07 01:51:29 +01:00
|
|
|
* @package Symfony
|
|
|
|
* @subpackage Framework_WebBundle
|
2010-02-17 13:55:05 +00:00
|
|
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*/
|
|
|
|
class ActionsHelper extends Helper
|
|
|
|
{
|
2010-05-18 12:05:03 +01:00
|
|
|
protected $manager;
|
2010-05-06 12:25:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param Constructor $container A ContainerInterface instance
|
|
|
|
*/
|
2010-05-18 12:05:03 +01:00
|
|
|
public function __construct(ControllerManager $manager)
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
2010-05-18 12:05:03 +01:00
|
|
|
$this->manager = $manager;
|
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-05-13 19:23:23 +01:00
|
|
|
* @param array $options An array of options
|
2010-05-18 12:05:03 +01:00
|
|
|
*
|
|
|
|
* @see Symfony\Framework\WebBundle\Controller\ControllerManager::render()
|
2010-05-13 07:29:04 +01:00
|
|
|
*/
|
2010-05-14 10:22:20 +01:00
|
|
|
public function render($controller, array $options = array())
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
2010-05-18 12:05:03 +01:00
|
|
|
if (isset($options['path']))
|
|
|
|
{
|
|
|
|
$options['path'] = Escaper::unescape($options['path']);
|
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-05-18 12:05:03 +01:00
|
|
|
return $this->manager->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
|
|
|
}
|