Issue #3474692 by longwave, foxtrotcharlie, bbrala: Fix "Twig\Node\Expression\FilterExpression" deprecation introduced in twig/twig 3.12.0
(cherry picked from commit 336ba833bc
)
merge-requests/9680/head
parent
e51c4c7178
commit
ec293e3f12
|
@ -64,13 +64,9 @@
|
|||
%The "Drupal\\Tests\\Core\\Utility\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
|
||||
|
||||
# Twig 3.
|
||||
%Since twig/twig 3.11: Changing the value of a "filter" node in a NodeVisitor class is not supported anymore.%
|
||||
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "attach_library" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
|
||||
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "add_component_context" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
|
||||
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "render_var" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
|
||||
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "validate_component_props" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
|
||||
%Since twig/twig 3.12: Getting node "filter" on a "Twig\\Node\\Expression\\FilterExpression" class is deprecated.%
|
||||
%Since twig/twig 3.12: Getting node "filter" on a "Twig\\Node\\Expression\\Filter\\DefaultFilter" class is deprecated.%
|
||||
%Since twig/twig 3.12: Getting node "filter" on a "Twig\\Node\\Expression\\Filter\\RawFilter" class is deprecated.%
|
||||
%Since twig/twig 3.12: The "tag" constructor argument of the "Drupal\\Core\\Template\\TwigNodeTrans" class is deprecated and ignored%
|
||||
%Since twig/twig 3.12: Twig Filter "spaceless" is deprecated%
|
||||
|
|
|
@ -145,7 +145,7 @@ class TwigNodeTrans extends Node {
|
|||
// @see TwigExtension::getFilters()
|
||||
$argPrefix = '@';
|
||||
while ($args instanceof FilterExpression) {
|
||||
switch ($args->getNode('filter')->getAttribute('value')) {
|
||||
switch ($args->getAttribute('twig_callable')->getName()) {
|
||||
case 'placeholder':
|
||||
$argPrefix = '%';
|
||||
break;
|
||||
|
|
|
@ -53,10 +53,10 @@ class TwigNodeVisitor implements NodeVisitorInterface {
|
|||
}
|
||||
// Change the 'escape' filter to our own 'drupal_escape' filter.
|
||||
elseif ($node instanceof FilterExpression) {
|
||||
$name = $node->getNode('filter')->getAttribute('value');
|
||||
$name = $node->getAttribute('twig_callable')->getName();
|
||||
if ('escape' == $name || 'e' == $name) {
|
||||
// Use our own escape filter that is MarkupInterface aware.
|
||||
$node->getNode('filter')->setAttribute('value', 'drupal_escape');
|
||||
$node->setAttribute('twig_callable', $env->getFilter('drupal_escape'));
|
||||
|
||||
// Store that we have a filter active already that knows
|
||||
// how to deal with render arrays.
|
||||
|
|
Loading…
Reference in New Issue