protected static function evaluateCondition($arguments = null, RenderingContextInterface $renderingContext)
{
$objectManager = $renderingContext->getObjectManager();
/** @var PolicyService $policyService */
$policyService = $objectManager->get(PolicyService::class);
/** @var Context $securityContext */
$securityContext = $objectManager->get(Context::class);
$role = $arguments['role'];
$account = $arguments['account'];
$packageKey = isset($arguments['packageKey']) ? $arguments['packageKey'] : $renderingContext->getControllerContext()->getRequest()->getControllerPackageKey();
if (is_string($role)) {
$roleIdentifier = $role;
if (in_array($roleIdentifier, ['Everybody', 'Anonymous', 'AuthenticatedUser'])) {
$roleIdentifier = 'Neos.Flow:' . $roleIdentifier;
}
if (strpos($roleIdentifier, '.') === false && strpos($roleIdentifier, ':') === false) {
$roleIdentifier = $packageKey . ':' . $roleIdentifier;
}
$role = $policyService->getRole($roleIdentifier);
}
$hasRole = $securityContext->hasRole($role->getIdentifier());
if ($account instanceof Account) {
$hasRole = $account->hasRole($role);
}
return $hasRole;
}