protected function isAllowed(ServerRequestInterface $request, string $role): bool
    {
        $route = $request->getAttribute('route');
        // Get config string like 'routes./home.second.rbac.anonymous' to get rbac config for route with name "second" in route group "home"
        $config = 'routes.'.$route->getGroups()[0]->getPattern().'.'.\strtr('/'.$route->getName(), [$route->getGroups()[0]->getPattern() => '', '-' => '']).'.rbac.'.$role;
        if (\in_array($request->getMethod(), $this->config($config, []), true)) {
            return true;
        }

        return false;
    }
protected function isAllowed(ServerRequestInterface $request, string $role): bool
    {
        $route = $request->getAttribute('route');
        // Get config string like 'routes./home.second.rbac.anonymous' to get rbac config for route with name "second" in route group "home"
        $config = 'routes.'.$route->getGroups()[0]->getPattern().'.'.\strtr('/'.$route->getName(), [$route->getGroups()[0]->getPattern() => '', '-' => '']).'.rbac.'.$role;
        if (\in_array($request->getMethod(), $this->config($config, []), true)) {
            return true;
        }

        return false;
    }
protected function isAllowed ( ServerRequestInterface $ request , string $ role ) : bool { $ route = $ request -> getAttribute ( 'route' ) ; // Get config string like 'routes./home.second.rbac.anonymous' to get rbac config for route with name "second" in route group "home" $ config = 'routes.' . $ route -> getGroups ( ) [ 0 ] -> getPattern ( ) . '.' . \ strtr ( '/' . $ route -> getName ( ) , [ $ route -> getGroups ( ) [ 0 ] -> getPattern ( ) => '' , '-' => '' ] ) . '.rbac.' . $ role ; if ( \ in_array ( $ request -> getMethod ( ) , $ this -> config ( $ config , [ ] ) , true ) ) { return true ; } return false ; }
Check if request allowed for current user.

@param ServerRequestInterface $request
@param string                 $role

@return bool
Check if request allowed for current user .