Skip to content
Snippets Groups Projects
Commit 89c44b0c authored by Tom Keitel's avatar Tom Keitel Committed by Pierre Dureau
Browse files

Issue #3483939 by hctom: Compatibility with Twig 3.12

parent 7431f5dd
No related branches found
No related tags found
1 merge request!252Issue #3483939 by hctom: Compatibility with Twig 3.12
Pipeline #324106 passed
......@@ -13,6 +13,7 @@ use Twig\Node\ModuleNode;
use Twig\Node\Node;
use Twig\Node\PrintNode;
use Twig\NodeVisitor\NodeVisitorInterface;
use Twig\TwigFunction;
/**
* Provides a ComponentNodeVisitor to change the generated parse-tree.
......@@ -60,7 +61,7 @@ class ComponentNodeVisitor implements NodeVisitorInterface {
return $node;
}
$line = $node->getTemplateLine();
$function = $this->buildPreprocessPropsFunction($line, $component);
$function = $this->buildPreprocessPropsFunction($line, $component, $env);
$node = $this->injectFunction($node, $function);
return $node;
}
......@@ -111,15 +112,21 @@ class ComponentNodeVisitor implements NodeVisitorInterface {
* The line .
* @param \Drupal\Core\Plugin\Component $component
* The component.
* @param \Twig\Environment $env
* A Twig Environment instance.
*
* @return \Twig\Node\Node
* The Twig function.
*/
protected function buildPreprocessPropsFunction(int $line, Component $component): Node {
protected function buildPreprocessPropsFunction(int $line, Component $component, Environment $env): Node {
$component_id = $component->getPluginId();
$function_parameter = new ConstantExpression($component_id, $line);
$function_parameters_node = new Node([$function_parameter]);
$function = new FunctionExpression('_ui_patterns_preprocess_props', $function_parameters_node, $line);
$function = new FunctionExpression(
new TwigFunction('_ui_patterns_preprocess_props', [$env->getExtension(TwigExtension::class), 'preprocessProps'], ['needs_context' => TRUE]),
$function_parameters_node,
$line
);
return new PrintNode($function, $line);
}
......
name: "UI Patterns"
type: module
description: "Define and expose self-contained UI Components as Drupal plugins and use them seamlessly in Drupal development and site-building."
core_version_requirement: ^10.3 || ^11
core_version_requirement: ^10.3.4 || ^11
package: "User interface"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment