ZfcRbac\Options\ModuleOptions::setProtectionPolicy PHP Method

setProtectionPolicy() public method

Set the protection policy for guards
public setProtectionPolicy ( string $protectionPolicy ) : void
$protectionPolicy string
return void
    public function setProtectionPolicy($protectionPolicy)
    {
        if ($protectionPolicy !== GuardInterface::POLICY_ALLOW && $protectionPolicy !== GuardInterface::POLICY_DENY) {
            throw new Exception\RuntimeException(sprintf('An invalid protection policy was set. Can only be "deny" or "allow", "%s" given', $protectionPolicy));
        }
        $this->protectionPolicy = (string) $protectionPolicy;
    }

Usage Example

Exemplo n.º 1
0
 public function testThrowExceptionForInvalidProtectionPolicy()
 {
     $this->setExpectedException('ZfcRbac\\Exception\\RuntimeException');
     $moduleOptions = new ModuleOptions();
     $moduleOptions->setProtectionPolicy('invalid');
 }