You are here

public function Twig_Sandbox_SecurityPolicy::checkSecurity in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php \Twig_Sandbox_SecurityPolicy::checkSecurity()

Overrides Twig_Sandbox_SecurityPolicyInterface::checkSecurity

File

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_SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
    }
  }
  foreach ($filters as $filter) {
    if (!in_array($filter, $this->allowedFilters)) {
      throw new Twig_Sandbox_SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
    }
  }
  foreach ($functions as $function) {
    if (!in_array($function, $this->allowedFunctions)) {
      throw new Twig_Sandbox_SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
    }
  }
}