class TwigAllowed

Allow twig access to methods.

Twig "sandboxes" templates to prevent them from

  • having unwanted side effects (like calling node.delete())
  • getting access to information outside the sandbox

This access attribute must only be given to methods that can not break the sandbox.

Note that Twig is not only used in templating, but also as a templating and configuration language in core (e.g. views) and custom modules, which makes its power available to site builders and maybe even site users with proper permissions.

Attributes

#[\Attribute(\Attribute::TARGET_METHOD)]

Hierarchy

Expanded class hierarchy of TwigAllowed

2 files declare their use of TwigAllowed
TwigSandboxPolicy.php in core/lib/Drupal/Core/Template/TwigSandboxPolicy.php
TwigSandboxTest.php in core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php

File

core/lib/Drupal/Core/Template/Attribute/TwigAllowed.php, line 20

Namespace

Drupal\Core\Template\Attribute
View source
final class TwigAllowed {

}

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