2121use Twig \Node \Expression \Ternary \ConditionalTernary ;
2222use Twig \Node \Node ;
2323use Twig \Node \Nodes ;
24- use Twig \NodeVisitor \AbstractNodeVisitor ;
2524use Twig \TwigFilter ;
2625
2726/**
@@ -50,14 +49,14 @@ public function doEnterNode(Node $node, Environment $env): Node
5049 return $ node ;
5150 }
5251
53- if (!($ node instanceof FilterExpression && 'desc ' === $ node -> getNode ( ' filter ' )-> getAttribute ( ' value ' ))) {
52+ if (!($ node instanceof FilterExpression && 'desc ' === $ this -> getValueFromNode ( $ node ))) {
5453 return $ node ;
5554 }
5655
5756 $ transNode = $ node ->getNode ('node ' );
5857 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 )) {
6160 $ transNode = $ transNode ->getNode ('node ' );
6261 }
6362
@@ -72,7 +71,7 @@ public function doEnterNode(Node $node, Environment $env): Node
7271 // if the |transchoice filter is used, delegate the call to the TranslationExtension
7372 // so that we can catch a possible exception when the default translation has not yet
7473 // been extracted
75- if ('transchoice ' === $ transNode -> getNode ( ' filter ' )-> getAttribute ( ' value ' )) {
74+ if ('transchoice ' === $ this -> getValueFromNode ( $ transNode )) {
7675 $ transchoiceArguments = new ArrayExpression ([], $ transNode ->getTemplateLine ());
7776 $ transchoiceArguments ->addElement ($ wrappingNode ->getNode ('node ' ));
7877 $ transchoiceArguments ->addElement ($ defaultNode );
@@ -150,4 +149,14 @@ public function getPriority(): int
150149 {
151150 return -2 ;
152151 }
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+ }
153162}
0 commit comments