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_NodeVisitorInterface; |
10
|
|
|
use Twig_NodeInterface; |
11
|
|
|
use Twig_Environment; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class RenderAddEmbedParamsNodeVisitor |
15
|
|
|
* |
16
|
|
|
* @package Zicht\Bundle\FrameworkExtraBundle\Twig |
17
|
|
|
*/ |
18
|
|
|
class RenderAddEmbedParamsNodeVisitor implements Twig_NodeVisitorInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Called before child nodes are visited. |
22
|
|
|
* |
23
|
|
|
* @param \Twig_NodeInterface $node The node to visit |
24
|
|
|
* @param \Twig_Environment $env The Twig environment instance |
25
|
|
|
* |
26
|
|
|
* @return \Twig_NodeInterface The modified node |
27
|
|
|
*/ |
28
|
|
|
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) |
29
|
|
|
{ |
30
|
|
|
return $node; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Called after child nodes are visited. |
35
|
|
|
* |
36
|
|
|
* @param \Twig_NodeInterface $node The node to visit |
37
|
|
|
* @param \Twig_Environment $env The Twig environment instance |
38
|
|
|
* |
39
|
|
|
* @return \Twig_NodeInterface The modified node |
40
|
|
|
*/ |
41
|
|
|
public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) |
42
|
|
|
{ |
43
|
|
|
if ($node instanceof \Twig_Node_Expression_Function) { |
44
|
|
|
if ($node->getAttribute('name') === 'controller') { |
45
|
|
|
$args = $node->getNode('arguments'); |
46
|
|
|
if (!$args->hasNode(1)) { |
47
|
|
|
$args->setNode(1, new \Twig_Node_Expression_Array(array(), $node->getLine())); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
$args->setNode( |
50
|
|
|
1, |
51
|
|
|
new \Twig_Node_Expression_Function( |
52
|
|
|
'embed', |
53
|
|
|
new \Twig_Node(array($args->getNode(1))), |
54
|
|
|
$node->getLine() |
|
|
|
|
55
|
|
|
) |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
return $node; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the priority for this visitor. |
64
|
|
|
* |
65
|
|
|
* Priority should be between -10 and 10 (0 is the default). |
66
|
|
|
* |
67
|
|
|
* @return integer The priority level |
68
|
|
|
*/ |
69
|
|
|
public function getPriority() |
70
|
|
|
{ |
71
|
|
|
return 0; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.