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

Returns the privilege target identified by the given string
public getPrivilegeTargetByIdentifier ( string $privilegeTargetIdentifier ) : PrivilegeTarget
$privilegeTargetIdentifier string Identifier of a privilege target
Результат Neos\Flow\Security\Authorization\Privilege\PrivilegeTarget
 /**
  * @test
  */
 public function getPrivilegeTargetByIdentifierReturnsTheConfiguredPrivilegeTarget()
 {
     $mockPrivilegeClassName = get_class($this->mockPrivilege);
     $this->mockPolicyConfiguration = ['privilegeTargets' => [$mockPrivilegeClassName => ['Some.PrivilegeTarget:Identifier' => ['matcher' => 'someMatcher()']]]];
     $privilegeTarget = $this->policyService->getPrivilegeTargetByIdentifier('Some.PrivilegeTarget:Identifier');
     $this->assertInstanceOf(PrivilegeTarget::class, $privilegeTarget);
     $this->assertSame('Some.PrivilegeTarget:Identifier', $privilegeTarget->getIdentifier());
 }
 /**
  * Shows the methods represented by the given security privilege target
  *
  * If the privilege target has parameters those can be specified separated by a colon
  * for example "parameter1:value1" "parameter2:value2".
  * But be aware that this only works for parameters that have been specified in the policy
  *
  * @param string $privilegeTarget The name of the privilegeTarget as stated in the policy
  * @return void
  */
 public function showMethodsForPrivilegeTargetCommand($privilegeTarget)
 {
     $privilegeTargetInstance = $this->policyService->getPrivilegeTargetByIdentifier($privilegeTarget);
     if ($privilegeTargetInstance === null) {
         $this->outputLine('The privilegeTarget "%s" is not defined', [$privilegeTarget]);
         $this->quit(1);
     }
     $privilegeParameters = [];
     foreach ($this->request->getExceedingArguments() as $argument) {
         list($argumentName, $argumentValue) = explode(':', $argument, 2);
         $privilegeParameters[$argumentName] = $argumentValue;
     }
     $privilege = $privilegeTargetInstance->createPrivilege(PrivilegeInterface::GRANT, $privilegeParameters);
     if (!$privilege instanceof MethodPrivilegeInterface) {
         $this->outputLine('The privilegeTarget "%s" does not refer to a MethodPrivilege but to a privilege of type "%s"', [$privilegeTarget, $privilege->getPrivilegeTarget()->getPrivilegeClassName()]);
         $this->quit(1);
     }
     $matchedClassesAndMethods = [];
     foreach ($this->reflectionService->getAllClassNames() as $className) {
         try {
             $reflectionClass = new \ReflectionClass($className);
         } catch (\ReflectionException $exception) {
             continue;
         }
         foreach ($reflectionClass->getMethods() as $reflectionMethod) {
             $methodName = $reflectionMethod->getName();
             if ($privilege->matchesMethod($className, $methodName)) {
                 $matchedClassesAndMethods[$className][$methodName] = $methodName;
             }
         }
     }
     if (count($matchedClassesAndMethods) === 0) {
         $this->outputLine('The given privilegeTarget did not match any method.');
         $this->quit(1);
     }
     foreach ($matchedClassesAndMethods as $className => $methods) {
         $this->outputLine($className);
         foreach ($methods as $methodName) {
             $this->outputLine('  ' . $methodName);
         }
         $this->outputLine();
     }
 }