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();
}
}