Neos\FluidAdaptor\ViewHelpers\Security\IfHasRoleViewHelper::evaluateCondition PHP Method

evaluateCondition() protected static method

protected static evaluateCondition ( null $arguments = null, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : boolean
$arguments null
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
return boolean
    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;
    }