Skip to content

Commit 604ecd2

Browse files
committed
refac: filter use attribute instate of node
1 parent 9b7e961 commit 604ecd2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Twig/Visitor/DefaultApplyingNodeVisitor.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public function doEnterNode(Node $node, Environment $env): Node
4747
return $node;
4848
}
4949

50-
if (!($node instanceof FilterExpression && 'desc' === $node->getNode('filter')->getAttribute('value'))) {
50+
if (!($node instanceof FilterExpression && 'desc' === $node->getAttribute('twig_callable')->getName())) {
5151
return $node;
5252
}
5353

5454
$transNode = $node->getNode('node');
5555
while ($transNode instanceof FilterExpression
56-
&& 'trans' !== $transNode->getNode('filter')->getAttribute('value')
57-
&& 'transchoice' !== $transNode->getNode('filter')->getAttribute('value')) {
56+
&& 'trans' !== $transNode->getAttribute('twig_callable')->getName()
57+
&& 'transchoice' !== $transNode->getAttribute('twig_callable')->getName()) {
5858
$transNode = $transNode->getNode('node');
5959
}
6060

@@ -69,7 +69,7 @@ public function doEnterNode(Node $node, Environment $env): Node
6969
// if the |transchoice filter is used, delegate the call to the TranslationExtension
7070
// so that we can catch a possible exception when the default translation has not yet
7171
// been extracted
72-
if ('transchoice' === $transNode->getNode('filter')->getAttribute('value')) {
72+
if ('transchoice' === $transNode->getAttribute('twig_callable')->getName()) {
7373
$transchoiceArguments = new ArrayExpression([], $transNode->getTemplateLine());
7474
$transchoiceArguments->addElement($wrappingNode->getNode('node'));
7575
$transchoiceArguments->addElement($defaultNode);

Twig/Visitor/RemovingNodeVisitor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function setEnabled(bool $bool): void
3636
protected function doEnterNode(Node $node, Environment $env): Node
3737
{
3838
if ($this->enabled && $node instanceof FilterExpression) {
39-
$name = $node->getNode('filter')->getAttribute('value');
39+
$name = $node->getAttribute('twig_callable')->getName();
4040

4141
if ('desc' === $name || 'meaning' === $name) {
4242
return $this->enterNode($node->getNode('node'), $env);

0 commit comments

Comments
 (0)