21
21
use Twig \Node \Expression \Ternary \ConditionalTernary ;
22
22
use Twig \Node \Node ;
23
23
use Twig \Node \Nodes ;
24
- use Twig \NodeVisitor \AbstractNodeVisitor ;
25
24
use Twig \TwigFilter ;
26
25
27
26
/**
@@ -50,14 +49,14 @@ public function doEnterNode(Node $node, Environment $env): Node
50
49
return $ node ;
51
50
}
52
51
53
- if (!($ node instanceof FilterExpression && 'desc ' === $ node -> getNode ( ' filter ' )-> getAttribute ( ' value ' ))) {
52
+ if (!($ node instanceof FilterExpression && 'desc ' === $ this -> getValueFromNode ( $ node ))) {
54
53
return $ node ;
55
54
}
56
55
57
56
$ transNode = $ node ->getNode ('node ' );
58
57
while ($ transNode instanceof FilterExpression
59
- && 'trans ' !== $ transNode -> getNode ( ' filter ' )-> getAttribute ( ' value ' )
60
- && 'transchoice ' !== $ transNode -> getNode ( ' filter ' )-> getAttribute ( ' value ' )) {
58
+ && 'trans ' !== $ this -> getValueFromNode ( $ transNode )
59
+ && 'transchoice ' !== $ this -> getValueFromNode ( $ transNode )) {
61
60
$ transNode = $ transNode ->getNode ('node ' );
62
61
}
63
62
@@ -72,7 +71,7 @@ public function doEnterNode(Node $node, Environment $env): Node
72
71
// if the |transchoice filter is used, delegate the call to the TranslationExtension
73
72
// so that we can catch a possible exception when the default translation has not yet
74
73
// been extracted
75
- if ('transchoice ' === $ transNode -> getNode ( ' filter ' )-> getAttribute ( ' value ' )) {
74
+ if ('transchoice ' === $ this -> getValueFromNode ( $ transNode )) {
76
75
$ transchoiceArguments = new ArrayExpression ([], $ transNode ->getTemplateLine ());
77
76
$ transchoiceArguments ->addElement ($ wrappingNode ->getNode ('node ' ));
78
77
$ transchoiceArguments ->addElement ($ defaultNode );
@@ -150,4 +149,14 @@ public function getPriority(): int
150
149
{
151
150
return -2 ;
152
151
}
152
+
153
+ public function enterNode (Node $ node , Environment $ env ): Node
154
+ {
155
+ return $ this ->doEnterNode ($ node , $ env );
156
+ }
157
+
158
+ public function leaveNode (Node $ node , Environment $ env ): ?Node
159
+ {
160
+ return $ this ->doLeaveNode ($ node , $ env );
161
+ }
153
162
}
0 commit comments