You are here

public function Twig_Sandbox_SecurityPolicy::checkPropertyAllowed 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::checkPropertyAllowed()

Overrides Twig_Sandbox_SecurityPolicyInterface::checkPropertyAllowed

File

vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php, line 104

Class

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

Code

public function checkPropertyAllowed($obj, $property) {
  $allowed = false;
  foreach ($this->allowedProperties as $class => $properties) {
    if ($obj instanceof $class) {
      $allowed = in_array($property, is_array($properties) ? $properties : array(
        $properties,
      ));
      break;
    }
  }
  if (!$allowed) {
    throw new Twig_Sandbox_SecurityError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, get_class($obj)));
  }
}