function TwigExtension::checkDeprecations

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::checkDeprecations()

Triggers a deprecation error if a variable is deprecated.

Parameters

array $context: A Twig context array.

array $used_variables: The names of the variables used in a template.

See also

\Drupal\Core\Template\TwigNodeCheckDeprecations

File

core/lib/Drupal/Core/Template/TwigExtension.php, line 735

Class

TwigExtension
A class providing Drupal Twig extensions.

Namespace

Drupal\Core\Template

Code

public function checkDeprecations(array $context, array $used_variables) : void {
  if (!isset($context['deprecations'])) {
    return;
  }
  foreach ($used_variables as $name) {
    if (isset($context['deprecations'][$name]) && \array_key_exists($name, $context)) {
      @trigger_error($context['deprecations'][$name], E_USER_DEPRECATED);
    }
  }
}

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