hasAccess() public method

Deprecation: since 6.6, to be removed. Use PermissionResolver::hasAccess() instead. Check if user has access to a given module / function. Low level function, use canUser instead if you have objects to check against.
public hasAccess ( string $module, string $function, eZ\Publish\API\Repository\Values\User\UserReference $user = null ) : boolean | array
$module string
$function string
$user eZ\Publish\API\Repository\Values\User\UserReference
return boolean | array Bool if user has full or no access, array if limitations if not
コード例 #1
0
ファイル: ContentService.php プロジェクト: ataxel/tp
    /**
     * Loads all incoming relations for a content object.
     *
     * The relations come only from published versions of the source content objects
     *
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
     *
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
     *
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
     */
    public function loadReverseRelations( ContentInfo $contentInfo )
    {
        if ( $this->repository->hasAccess( 'content', 'reverserelatedlist' ) !== true )
            throw new UnauthorizedException( 'content', 'reverserelatedlist', array( 'contentId' => $contentInfo->id ) );

        $spiRelations = $this->persistenceHandler->contentHandler()->loadReverseRelations(
            $contentInfo->id
        );

        $returnArray = array();
        foreach ( $spiRelations as $spiRelation )
        {
            $sourceContentInfo = $this->internalLoadContentInfo( $spiRelation->sourceContentId );
            if ( !$this->repository->canUser( 'content', 'read', $sourceContentInfo ) )
                continue;

            $returnArray[] = $this->domainMapper->buildRelationDomainObject(
                $spiRelation,
                $sourceContentInfo,
                $contentInfo
            );
        }

        return $returnArray;
    }