Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SecurityPolicy.php

function SecurityPolicy::checkPropertyAllowed

Overrides SecurityPolicyInterface::checkPropertyAllowed

File

vendor/twig/twig/src/Sandbox/SecurityPolicy.php, line 115

Class

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

Namespace

Twig\Sandbox

Code

public function checkPropertyAllowed($obj, $property) : void {
    $allowed = false;
    foreach ($this->allowedProperties as $class => $properties) {
        if ($obj instanceof $class && \in_array($property, \is_array($properties) ? $properties : [
            $properties,
        ])) {
            $allowed = true;
            break;
        }
    }
    if (!$allowed) {
        $class = \get_class($obj);
        throw new SecurityNotAllowedPropertyError(\sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property);
    }
}
RSS feed
Powered by Drupal