eZ\Publish\Core\Repository\Helper\DomainMapper::buildContentInfoDomainObject PHP Method

buildContentInfoDomainObject() public method

Builds a ContentInfo domain object from value object returned from persistence.
public buildContentInfoDomainObject ( eZ\Publish\SPI\Persistence\Content\ContentInfo $spiContentInfo ) : eZ\Publish\API\Repository\Values\Content\ContentInfo
$spiContentInfo eZ\Publish\SPI\Persistence\Content\ContentInfo
return eZ\Publish\API\Repository\Values\Content\ContentInfo
    public function buildContentInfoDomainObject(SPIContentInfo $spiContentInfo)
    {
        return new ContentInfo(array('id' => $spiContentInfo->id, 'contentTypeId' => $spiContentInfo->contentTypeId, 'name' => $spiContentInfo->name, 'sectionId' => $spiContentInfo->sectionId, 'currentVersionNo' => $spiContentInfo->currentVersionNo, 'published' => $spiContentInfo->isPublished, 'ownerId' => $spiContentInfo->ownerId, 'modificationDate' => $spiContentInfo->modificationDate == 0 ? null : $this->getDateTime($spiContentInfo->modificationDate), 'publishedDate' => $spiContentInfo->publicationDate == 0 ? null : $this->getDateTime($spiContentInfo->publicationDate), 'alwaysAvailable' => $spiContentInfo->alwaysAvailable, 'remoteId' => $spiContentInfo->remoteId, 'mainLanguageCode' => $spiContentInfo->mainLanguageCode, 'mainLocationId' => $spiContentInfo->mainLocationId));
    }

Usage Example

Example #1
0
 /**
  * Finds contentInfo objects for the given query.
  *
  * @see SearchServiceInterface::findContentInfo()
  *
  * @since 5.4.5
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Query $query
  * @param array $languageFilter - a map of filters for the returned fields.
  *        Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
  *                            useAlwaysAvailable defaults to true to avoid exceptions on missing translations.
  * @param bool $filterOnUserPermissions if true (default) only the objects which is the user allowed to read are returned.
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
  */
 public function findContentInfo(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true)
 {
     $result = $this->internalFindContentInfo($query, $languageFilter, $filterOnUserPermissions);
     foreach ($result->searchHits as $hit) {
         $hit->valueObject = $this->domainMapper->buildContentInfoDomainObject($hit->valueObject);
     }
     return $result;
 }
All Usage Examples Of eZ\Publish\Core\Repository\Helper\DomainMapper::buildContentInfoDomainObject