DecoratedRenderNode::compile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 1
eloc 11
c 2
b 1
f 1
nc 1
nop 1
dl 0
loc 13
rs 9.9
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Bundle\FrameworkExtraBundle\Twig;
8
9
use Twig_Compiler;
10
use Symfony\Bundle\TwigBundle\Node\RenderNode as BaseRenderNode;
11
12
/**
13
 * This decorator makes sure that if a {% render ... %} is used in Twig, the embed parameters (success_url, return_url)
14
 * are added to the request.
15
 *
16
 * TwigExtension::embedParams() is used for this.
17
 */
18
class DecoratedRenderNode extends \Twig_Node
19
{
20
    /**
21
     * DecoratedRenderNode constructor.
22
     *
23
     * @param BaseRenderNode $wrappedNode
24
     */
25
    public function __construct(BaseRenderNode $wrappedNode)
26
    {
27
        parent::__construct();
28
        $this->wrapped = $wrappedNode;
0 ignored issues
show
Bug Best Practice introduced by
The property wrapped does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
    }
30
31
    /**
32
     * Compile
33
     *
34
     * @param Twig_Compiler $compiler
35
     */
36
    public function compile(Twig_Compiler $compiler)
37
    {
38
        $compiler
39
            ->addDebugInfo($this)
40
            ->write("echo \$this->env->getExtension('actions')->renderAction(")
41
            ->subcompile($this->wrapped->getNode('expr'))
42
            ->raw(', ')
43
            ->raw("\$this->env->getExtension('zicht_framework_extra')->embed(")
44
            ->subcompile($this->wrapped->getNode('attributes'))
45
            ->raw(')')
46
            ->raw(', ')
47
            ->subcompile($this->wrapped->getNode('options'))
48
            ->raw(");\n");
49
    }
50
}
51