|
11 | 11 |
|
12 | 12 | namespace Symfony\Bridge\Twig\Extension; |
13 | 13 |
|
14 | | -use Symfony\Component\HttpKernel\HttpContentRenderer; |
| 14 | +use Symfony\Component\HttpKernel\Fragment\FragmentHandler; |
15 | 15 | use Symfony\Component\HttpKernel\Controller\ControllerReference; |
16 | 16 |
|
17 | 17 | /** |
|
21 | 21 | */ |
22 | 22 | class HttpKernelExtension extends \Twig_Extension |
23 | 23 | { |
24 | | - private $renderer; |
| 24 | + private $handler; |
25 | 25 |
|
26 | 26 | /** |
27 | 27 | * Constructor. |
28 | 28 | * |
29 | | - * @param HttpContentRenderer $renderer A HttpContentRenderer instance |
| 29 | + * @param FragmentHandler $handler A FragmentHandler instance |
30 | 30 | */ |
31 | | - public function __construct(HttpContentRenderer $renderer) |
| 31 | + public function __construct(FragmentHandler $handler) |
32 | 32 | { |
33 | | - $this->renderer = $renderer; |
| 33 | + $this->handler = $handler; |
34 | 34 | } |
35 | 35 |
|
36 | 36 | public function getFunctions() |
37 | 37 | { |
38 | 38 | return array( |
39 | | - 'render' => new \Twig_Function_Method($this, 'render', array('is_safe' => array('html'))), |
40 | | - 'render_*' => new \Twig_Function_Method($this, 'renderStrategy', array('is_safe' => array('html'))), |
| 39 | + 'render' => new \Twig_Function_Method($this, 'renderFragment', array('is_safe' => array('html'))), |
| 40 | + 'render_*' => new \Twig_Function_Method($this, 'renderFragmentStrategy', array('is_safe' => array('html'))), |
41 | 41 | 'controller' => new \Twig_Function_Method($this, 'controller'), |
42 | 42 | ); |
43 | 43 | } |
44 | 44 |
|
45 | 45 | /** |
46 | | - * Renders a URI. |
| 46 | + * Renders a fragment. |
47 | 47 | * |
48 | 48 | * @param string $uri A URI |
49 | 49 | * @param array $options An array of options |
50 | 50 | * |
51 | | - * @return string The Response content |
| 51 | + * @return string The fragment content |
52 | 52 | * |
53 | | - * @see Symfony\Component\HttpKernel\HttpContentRenderer::render() |
| 53 | + * @see Symfony\Component\HttpKernel\Fragment\FragmentHandler::render() |
54 | 54 | */ |
55 | | - public function render($uri, $options = array()) |
| 55 | + public function renderFragment($uri, $options = array()) |
56 | 56 | { |
57 | | - $options = $this->renderer->fixOptions($options); |
| 57 | + $options = $this->handler->fixOptions($options); |
58 | 58 |
|
59 | | - $strategy = isset($options['strategy']) ? $options['strategy'] : 'default'; |
| 59 | + $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; |
60 | 60 | unset($options['strategy']); |
61 | 61 |
|
62 | | - return $this->renderer->render($uri, $strategy, $options); |
| 62 | + return $this->handler->render($uri, $strategy, $options); |
63 | 63 | } |
64 | 64 |
|
65 | | - public function renderStrategy($strategy, $uri, $options = array()) |
| 65 | + /** |
| 66 | + * Renders a fragment. |
| 67 | + * |
| 68 | + * @param string $strategy A strategy name |
| 69 | + * @param string $uri A URI |
| 70 | + * @param array $options An array of options |
| 71 | + * |
| 72 | + * @return string The fragment content |
| 73 | + * |
| 74 | + * @see Symfony\Component\HttpKernel\Fragment\FragmentHandler::render() |
| 75 | + */ |
| 76 | + public function renderFragmentStrategy($strategy, $uri, $options = array()) |
66 | 77 | { |
67 | | - return $this->renderer->render($uri, $strategy, $options); |
| 78 | + return $this->handler->render($uri, $strategy, $options); |
68 | 79 | } |
69 | 80 |
|
70 | 81 | public function controller($controller, $attributes = array(), $query = array()) |
|
0 commit comments