src/Component/BaseComponent.php
public function checkAccess($userId, $permissionName)
    {
        if (ValidatorHelper::isInteger($userId) == false) {
            throw new InvalidArgumentException('User identifier must be number.');
        }

        /** @var integer $permissionId */
        $permissionId = $this->repositoryRegistry
            ->getPermissionRepository()
            ->getPermissionIdByName($permissionName);

        if (ValidatorHelper::isInteger($permissionId)) {

            /** @var integer[] $rootRoleIds */
            $rootRoleIds = $this->repositoryRegistry
                ->getUserRoleRepository()
                ->getUserRoleIds($userId);

            if (count($rootRoleIds) > 0) {

                /** @var integer[] $allRoleIds */
                $allRoleIds = $this->repositoryRegistry
                    ->getRoleHierarchyRepository()
                    ->getAllRoleIdsHierarchy($rootRoleIds);

                return $this->repositoryRegistry
                    ->getRolePermissionRepository()
                    ->isPermissionAssigned($permissionId, $allRoleIds);
            }
        }

        return false;
    }
public function checkAccess($userId, $permissionName)
    {
        if (ValidatorHelper::isInteger($userId) == false) {
            throw new InvalidArgumentException('User identifier must be number.');
        }

        /** @var integer $permissionId */
        $permissionId = $this->repositoryRegistry
            ->getPermissionRepository()
            ->getPermissionIdByName($permissionName);

        if (ValidatorHelper::isInteger($permissionId)) {

            /** @var integer[] $rootRoleIds */
            $rootRoleIds = $this->repositoryRegistry
                ->getUserRoleRepository()
                ->getUserRoleIds($userId);

            if (count($rootRoleIds) > 0) {

                /** @var integer[] $allRoleIds */
                $allRoleIds = $this->repositoryRegistry
                    ->getRoleHierarchyRepository()
                    ->getAllRoleIdsHierarchy($rootRoleIds);

                return $this->repositoryRegistry
                    ->getRolePermissionRepository()
                    ->isPermissionAssigned($permissionId, $allRoleIds);
            }
        }

        return false;
    }
public function checkAccess ( $ userId , $ permissionName ) { if ( ValidatorHelper :: isInteger ( $ userId ) == false ) { throw new InvalidArgumentException ( 'User identifier must be number.' ) ; } /** @var integer $permissionId */ $ permissionId = $ this -> repositoryRegistry -> getPermissionRepository ( ) -> getPermissionIdByName ( $ permissionName ) ; if ( ValidatorHelper :: isInteger ( $ permissionId ) ) { /** @var integer[] $rootRoleIds */ $ rootRoleIds = $ this -> repositoryRegistry -> getUserRoleRepository ( ) -> getUserRoleIds ( $ userId ) ; if ( count ( $ rootRoleIds ) > 0 ) { /** @var integer[] $allRoleIds */ $ allRoleIds = $ this -> repositoryRegistry -> getRoleHierarchyRepository ( ) -> getAllRoleIdsHierarchy ( $ rootRoleIds ) ; return $ this -> repositoryRegistry -> getRolePermissionRepository ( ) -> isPermissionAssigned ( $ permissionId , $ allRoleIds ) ; } } return false ; }
Checks access status
@param integer $userId
@param string $permissionName
@return bool
@throws InvalidArgumentException
@throws \Doctrine\ORM\Query\QueryException
Checks access status