]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
1 | <?php |
2 | ||
3 | /* | |
4 | * This file is part of the Symfony package. | |
5 | * | |
6 | * (c) Fabien Potencier <fabien@symfony.com> | |
7 | * | |
8 | * For the full copyright and license information, please view the LICENSE | |
9 | * file that was distributed with this source code. | |
10 | */ | |
11 | ||
12 | namespace Symfony\Bridge\Twig\Node; | |
13 | ||
14 | /** | |
15 | * Compiles a call to {@link FormRendererInterface::renderBlock()}. | |
16 | * | |
17 | * The function name is used as block name. For example, if the function name | |
18 | * is "foo", the block "foo" will be rendered. | |
19 | * | |
20 | * @author Bernhard Schussek <bschussek@gmail.com> | |
21 | */ | |
22 | class RenderBlockNode extends \Twig_Node_Expression_Function | |
23 | { | |
24 | public function compile(\Twig_Compiler $compiler) | |
25 | { | |
26 | $compiler->addDebugInfo($this); | |
27 | $arguments = iterator_to_array($this->getNode('arguments')); | |
28 | $compiler->write('$this->env->getExtension(\'form\')->renderer->renderBlock('); | |
29 | ||
30 | if (isset($arguments[0])) { | |
31 | $compiler->subcompile($arguments[0]); | |
32 | $compiler->raw(', \'' . $this->getAttribute('name') . '\''); | |
33 | ||
34 | if (isset($arguments[1])) { | |
35 | $compiler->raw(', '); | |
36 | $compiler->subcompile($arguments[1]); | |
37 | } | |
38 | } | |
39 | ||
40 | $compiler->raw(')'); | |
41 | } | |
42 | } |