You are here

final protected function Twig_Template::getContext in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Template.php \Twig_Template::getContext()

Returns a variable from the context.

This method is for internal use only and should never be called directly.

This method should not be overridden in a sub-class as this is an implementation detail that has been introduced to optimize variable access for versions of PHP before 5.4. This is not a way to override the way to get a variable value.

@internal

Parameters

array $context The context:

string $item The variable to return from the context:

bool $ignoreStrictCheck Whether to ignore the strict variable check or not:

Return value

mixed The content of the context variable

Throws

Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode

File

vendor/twig/twig/lib/Twig/Template.php, line 429

Class

Twig_Template
Default base class for compiled templates.

Code

protected final function getContext($context, $item, $ignoreStrictCheck = false) {
  if (!array_key_exists($item, $context)) {
    if ($ignoreStrictCheck || !$this->env
      ->isStrictVariables()) {
      return;
    }
    throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item), -1, $this
      ->getTemplateName());
  }
  return $context[$item];
}