/** * Performs a query for a single content object * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if criterion is not valid * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is more than one result matching the criterions * * @todo define structs for the field filters * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter * @param array $fieldFilters - a map of filters for the returned fields. * Currently supported: <code>array("languages" => array(<language1>,..))</code>. * @param boolean $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. * * @return \eZ\Publish\API\Repository\Values\Content\Content */ public function findSingle(Criterion $filter, array $fieldFilters = array(), $filterOnUserPermissions = true) { $this->validateContentCriteria(array($filter), "\$filter"); if ($filterOnUserPermissions && !$this->permissionsCriterionHandler->addPermissionsCriterion($filter)) { throw new NotFoundException('Content', '*'); } return $this->domainMapper->buildContentDomainObject($this->searchHandler->findSingle($filter, $fieldFilters)); }
/** * Publishes a content version * * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft * * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo * @param int|null $publicationDate * * @return \eZ\Publish\API\Repository\Values\Content\Content */ protected function internalPublishVersion(APIVersionInfo $versionInfo, $publicationDate = null) { if ($versionInfo->status !== APIVersionInfo::STATUS_DRAFT) { throw new BadStateException("\$versionInfo", "Only versions in draft status can be published."); } $metadataUpdateStruct = new SPIMetadataUpdateStruct(); $metadataUpdateStruct->publicationDate = isset($publicationDate) ? $publicationDate : time(); $metadataUpdateStruct->modificationDate = $metadataUpdateStruct->publicationDate; $spiContent = $this->persistenceHandler->contentHandler()->publish($versionInfo->getContentInfo()->id, $versionInfo->versionNo, $metadataUpdateStruct); $content = $this->domainMapper->buildContentDomainObject($spiContent); $this->publishUrlAliasesForContent($content); return $content; }