|
9 | 9 | use Drupal\Core\Render\Component\Exception\InvalidComponentException;
|
10 | 10 | use Drupal\Core\Theme\ComponentPluginManager;
|
11 | 11 | use Twig\Environment;
|
| 12 | +use Twig\TwigFunction; |
12 | 13 | use Twig\Node\Expression\ConstantExpression;
|
13 | 14 | use Twig\Node\Expression\FunctionExpression;
|
14 | 15 | use Twig\Node\ModuleNode;
|
@@ -55,17 +56,17 @@ public function leaveNode(Node $node, Environment $env): ?Node {
|
55 | 56 | $print_nodes[] = new PrintNode(new ConstantExpression(sprintf('<!-- %s Component start: %s -->', $emoji, $component_id), $line), $line);
|
56 | 57 | }
|
57 | 58 | $print_nodes[] = new PrintNode(new FunctionExpression(
|
58 |
| - 'attach_library', |
| 59 | + new TwigFunction('attach_library', [$env->getExtension(TwigExtension::class), 'attachLibrary']), |
59 | 60 | new Node([new ConstantExpression($component->getLibraryName(), $line)]),
|
60 | 61 | $line
|
61 | 62 | ), $line);
|
62 | 63 | $print_nodes[] = new PrintNode(new FunctionExpression(
|
63 |
| - 'add_component_context', |
| 64 | + new TwigFunction('add_component_context', [$env->getExtension(ComponentsTwigExtension::class), 'addAdditionalContext'], ['needs_context' => TRUE]), |
64 | 65 | new Node([new ConstantExpression($component_id, $line)]),
|
65 | 66 | $line
|
66 | 67 | ), $line);
|
67 | 68 | $print_nodes[] = new PrintNode(new FunctionExpression(
|
68 |
| - 'validate_component_props', |
| 69 | + new TwigFunction('validate_component_props', [$env->getExtension(ComponentsTwigExtension::class), 'validateProps'], ['needs_context' => TRUE]), |
69 | 70 | new Node([new ConstantExpression($component_id, $line)]),
|
70 | 71 | $line
|
71 | 72 | ), $line);
|
|
0 commit comments