function ComponentsTwigExtension::getFunctions

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Template/ComponentsTwigExtension.php \Drupal\Core\Template\ComponentsTwigExtension::getFunctions()

File

core/lib/Drupal/Core/Template/ComponentsTwigExtension.php, line 43

Class

ComponentsTwigExtension
The twig extension so Drupal can recognize the new code.

Namespace

Drupal\Core\Template

Code

public function getFunctions() : array {
    return [
        new TwigFunction('add_component_context', [
            $this,
            'addAdditionalContext',
        ], [
            'needs_context' => TRUE,
        ]),
        new TwigFunction('validate_component_props', [
            $this,
            'validateProps',
        ], [
            'needs_context' => TRUE,
        ]),
        // @todo remove in drupal:11.0.0.
        // @see https://www.drupal.org/project/drupal/issues/3409456.
        // Start of BC layer.
new TwigFunction('sdc_additional_context', [
            $this,
            'addAdditionalContext',
        ], [
            'needs_context' => TRUE,
            'deprecated' => '10.3.0',
            'alternative' => 'add_component_context',
        ]),
        new TwigFunction('sdc_validate_props', [
            $this,
            'validateProps',
        ], [
            'needs_context' => TRUE,
            'deprecated' => '10.3.0',
            'alternative' => 'validate_component_props',
        ]),
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.