public function isManager(ResourceNode $resourceNode)
    {
        $token = $this->tokenStorage->getToken();

        // if user is anonymous return false
        if ('anon.' === $token) {
            return false;
        }

        $roleNames = array_map(function (RoleInterface $role) {
            return $role->getRole();
        }, $token->getRoles());

        $isWorkspaceUsurp = in_array('ROLE_USURPATE_WORKSPACE_ROLE', $roleNames);

        $workspace = $resourceNode->getWorkspace();

        //if we manage the workspace
        if ($workspace && $this->container->get('claroline.manager.workspace_manager')->isManager($workspace, $token)) {
            return true;
        }

        // If not workspace usurper
        if (!$isWorkspaceUsurp && $token->getUser() === $resourceNode->getCreator()) {
            return true;
        }

        if (in_array('ROLE_ADMIN', $roleNames)) {
            return true;
        }

        return false;
    }
public function isManager(ResourceNode $resourceNode)
    {
        $token = $this->tokenStorage->getToken();

        // if user is anonymous return false
        if ('anon.' === $token) {
            return false;
        }

        $roleNames = array_map(function (RoleInterface $role) {
            return $role->getRole();
        }, $token->getRoles());

        $isWorkspaceUsurp = in_array('ROLE_USURPATE_WORKSPACE_ROLE', $roleNames);

        $workspace = $resourceNode->getWorkspace();

        //if we manage the workspace
        if ($workspace && $this->container->get('claroline.manager.workspace_manager')->isManager($workspace, $token)) {
            return true;
        }

        // If not workspace usurper
        if (!$isWorkspaceUsurp && $token->getUser() === $resourceNode->getCreator()) {
            return true;
        }

        if (in_array('ROLE_ADMIN', $roleNames)) {
            return true;
        }

        return false;
    }
public function isManager ( ResourceNode $ resourceNode ) { $ token = $ this -> tokenStorage -> getToken ( ) ; // if user is anonymous return false if ( 'anon.' === $ token ) { return false ; } $ roleNames = array_map ( function ( RoleInterface $ role ) { return $ role -> getRole ( ) ; } , $ token -> getRoles ( ) ) ; $ isWorkspaceUsurp = in_array ( 'ROLE_USURPATE_WORKSPACE_ROLE' , $ roleNames ) ; $ workspace = $ resourceNode -> getWorkspace ( ) ; //if we manage the workspace if ( $ workspace && $ this -> container -> get ( 'claroline.manager.workspace_manager' ) -> isManager ( $ workspace , $ token ) ) { return true ; } // If not workspace usurper if ( ! $ isWorkspaceUsurp && $ token -> getUser ( ) === $ resourceNode -> getCreator ( ) ) { return true ; } if ( in_array ( 'ROLE_ADMIN' , $ roleNames ) ) { return true ; } return false ; }
Checks if the current user is a manager of a resource.

A user is a manager of a resource if :
- It is the creator of the resource
- It is the manager of the parent workspace
- It is a platform admin

@param ResourceNode $resourceNode

@return bool
Checks if the current user is a manager of a resource .