public function Twig_Sandbox_SecurityPolicy::checkSecurity

Overrides Twig_Sandbox_SecurityPolicyInterface::checkSecurity

File

drupal/core/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php, line 62

Class

Twig_Sandbox_SecurityPolicy
Represents a security policy which need to be enforced when sandbox mode is enabled.

Code

public function checkSecurity($tags, $filters, $functions) {
  foreach ($tags as $tag) {
    if (!in_array($tag, $this->allowedTags)) {
      throw new Twig_Sandbox_SecurityError(sprintf('Tag "%s" is not allowed.', $tag));
    }
  }
  foreach ($filters as $filter) {
    if (!in_array($filter, $this->allowedFilters)) {
      throw new Twig_Sandbox_SecurityError(sprintf('Filter "%s" is not allowed.', $filter));
    }
  }
  foreach ($functions as $function) {
    if (!in_array($function, $this->allowedFunctions)) {
      throw new Twig_Sandbox_SecurityError(sprintf('Function "%s" is not allowed.', $function));
    }
  }
}