public function getCurrentPermissionArray(ResourceNode $resourceNode)
    {
        $currentRoles = $this->tokenStorage->getToken()->getRoles();

        $roleNames = array_map(function (RoleInterface $roleName) {
            return $roleName->getRole();
        }, $currentRoles);

        $creatable = [];
        if ($this->isManager($resourceNode)) {
            /** @var ResourceType[] $resourceTypes */
            $resourceTypes = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();

            foreach ($resourceTypes as $resourceType) {
                $creatable[] = $resourceType->getName();
            }

            $perms = array_fill_keys(array_values($this->maskManager->getPermissionMap($resourceNode->getResourceType())), true);
        } else {
            $creatable = $this->getCreatableTypes($roleNames, $resourceNode);

            $perms = $this->maskManager->decodeMask(
                $this->rightsRepo->findMaximumRights($roleNames, $resourceNode),
                $resourceNode->getResourceType()
            );
        }

        return array_merge($perms, ['create' => $creatable]);
    }
public function getCurrentPermissionArray(ResourceNode $resourceNode)
    {
        $currentRoles = $this->tokenStorage->getToken()->getRoles();

        $roleNames = array_map(function (RoleInterface $roleName) {
            return $roleName->getRole();
        }, $currentRoles);

        $creatable = [];
        if ($this->isManager($resourceNode)) {
            /** @var ResourceType[] $resourceTypes */
            $resourceTypes = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();

            foreach ($resourceTypes as $resourceType) {
                $creatable[] = $resourceType->getName();
            }

            $perms = array_fill_keys(array_values($this->maskManager->getPermissionMap($resourceNode->getResourceType())), true);
        } else {
            $creatable = $this->getCreatableTypes($roleNames, $resourceNode);

            $perms = $this->maskManager->decodeMask(
                $this->rightsRepo->findMaximumRights($roleNames, $resourceNode),
                $resourceNode->getResourceType()
            );
        }

        return array_merge($perms, ['create' => $creatable]);
    }
public function getCurrentPermissionArray ( ResourceNode $ resourceNode ) { $ currentRoles = $ this -> tokenStorage -> getToken ( ) -> getRoles ( ) ; $ roleNames = array_map ( function ( RoleInterface $ roleName ) { return $ roleName -> getRole ( ) ; } , $ currentRoles ) ; $ creatable = [ ] ; if ( $ this -> isManager ( $ resourceNode ) ) { /** @var ResourceType[] $resourceTypes */ $ resourceTypes = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Resource\ResourceType' ) -> findAll ( ) ; foreach ( $ resourceTypes as $ resourceType ) { $ creatable [ ] = $ resourceType -> getName ( ) ; } $ perms = array_fill_keys ( array_values ( $ this -> maskManager -> getPermissionMap ( $ resourceNode -> getResourceType ( ) ) ) , true ) ; } else { $ creatable = $ this -> getCreatableTypes ( $ roleNames , $ resourceNode ) ; $ perms = $ this -> maskManager -> decodeMask ( $ this -> rightsRepo -> findMaximumRights ( $ roleNames , $ resourceNode ) , $ resourceNode -> getResourceType ( ) ) ; } return array_merge ( $ perms , [ 'create' => $ creatable ] ) ; }
maybe use that one in the voter later because it's going to be usefull
maybe use that one in the voter later because it s going to be usefull