eZ\Publish\Core\Repository\ContentService::loadContentDrafts PHP Method

loadContentDrafts() public method

If no user is given the drafts for the authenticated user a returned
public loadContentDrafts ( eZ\Publish\API\Repository\Values\User\User $user = null ) : eZ\Publish\API\Repository\Values\Content\VersionInfo
$user eZ\Publish\API\Repository\Values\User\User
return eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user
    public function loadContentDrafts(User $user = null)
    {
        if ($user === null) {
            $user = $this->repository->getCurrentUserReference();
        }
        // throw early if user has absolutely no access to versionread
        if ($this->repository->hasAccess('content', 'versionread') === false) {
            throw new UnauthorizedException('content', 'versionread');
        }
        $spiVersionInfoList = $this->persistenceHandler->contentHandler()->loadDraftsForUser($user->getUserId());
        $versionInfoList = array();
        foreach ($spiVersionInfoList as $spiVersionInfo) {
            $versionInfo = $this->domainMapper->buildVersionInfoDomainObject($spiVersionInfo);
            if (!$this->repository->canUser('content', 'versionread', $versionInfo)) {
                throw new UnauthorizedException('content', 'versionread', array('contentId' => $versionInfo->contentInfo->id));
            }
            $versionInfoList[] = $versionInfo;
        }
        return $versionInfoList;
    }