Neos\Flow\Security\Authorization\PrivilegeManager::isGranted PHP Метод

isGranted() публичный Метод

Returns TRUE, if the given privilege type is granted for the given subject based on the current security context.
public isGranted ( string $privilegeType, mixed $subject, string &$reason = '' ) : boolean
$privilegeType string The type of privilege that should be evaluated
$subject mixed The subject to check privileges for
$reason string This variable will be filled by a message giving information about the reasons for the result of this method
Результат boolean
    public function isGranted($privilegeType, $subject, &$reason = '')
    {
        return $this->isGrantedForRoles($this->securityContext->getRoles(), $privilegeType, $subject, $reason);
    }

Usage Example

 /**
  * @test
  */
 public function isGrantedGrantsAccessIfAGrantPrivilegeAndNoDenyPrivilegeWasConfigured()
 {
     $role1ClassName = 'role1' . md5(uniqid(mt_rand(), true));
     $role2ClassName = 'role2' . md5(uniqid(mt_rand(), true));
     $mockRoleAdministrator = $this->createMock(Security\Policy\Role::class, [], [], $role1ClassName, false);
     $mockRoleAdministrator->expects($this->any())->method('getPrivilegesByType')->will($this->returnValue([$this->grantPrivilege]));
     $mockRoleCustomer = $this->createMock(Security\Policy\Role::class, [], [], $role2ClassName, false);
     $mockRoleCustomer->expects($this->any())->method('getPrivilegesByType')->will($this->returnValue([]));
     $this->mockSecurityContext->expects($this->once())->method('getRoles')->will($this->returnValue([$mockRoleAdministrator, $mockRoleCustomer]));
     $this->assertTrue($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, new MethodPrivilegeSubject($this->mockJoinPoint)));
 }
All Usage Examples Of Neos\Flow\Security\Authorization\PrivilegeManager::isGranted