public buildLocationDomainObject ( eZ\Publish\SPI\Persistence\Content\Location $spiLocation ) : eZ\Publish\API\Repository\Values\Content\Location | ||
$spiLocation | eZ\Publish\SPI\Persistence\Content\Location | |
Результат | eZ\Publish\API\Repository\Values\Content\Location |
public function buildLocationDomainObject(SPILocation $spiLocation)
{
// TODO: this is hardcoded workaround for missing ContentInfo on root location
if ($spiLocation->id == 1) {
$legacyDateTime = $this->getDateTime(1030968000);
// first known commit of eZ Publish 3.x
$contentInfo = new ContentInfo(array('id' => 0, 'name' => 'Top Level Nodes', 'sectionId' => 1, 'mainLocationId' => 1, 'contentTypeId' => 1, 'currentVersionNo' => 1, 'published' => 1, 'ownerId' => 14, 'modificationDate' => $legacyDateTime, 'publishedDate' => $legacyDateTime, 'alwaysAvailable' => 1, 'remoteId' => null, 'mainLanguageCode' => 'eng-GB'));
} else {
$contentInfo = $this->buildContentInfoDomainObject($this->contentHandler->loadContentInfo($spiLocation->contentId));
}
return new Location(array('contentInfo' => $contentInfo, 'id' => $spiLocation->id, 'priority' => $spiLocation->priority, 'hidden' => $spiLocation->hidden, 'invisible' => $spiLocation->invisible, 'remoteId' => $spiLocation->remoteId, 'parentLocationId' => $spiLocation->parentId, 'pathString' => $spiLocation->pathString, 'depth' => $spiLocation->depth, 'sortField' => $spiLocation->sortField, 'sortOrder' => $spiLocation->sortOrder));
}
/** * Finds Locations for the given query. * * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid * * @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query * @param boolean $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. * * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult */ public function findLocations(LocationQuery $query, $filterOnUserPermissions = true) { $query = clone $query; $query->filter = $query->filter ?: new Criterion\MatchAll(); $this->validateSortClauses($query); if ($filterOnUserPermissions && !$this->permissionsCriterionHandler->addPermissionsCriterion($query->filter)) { return new SearchResult(array('time' => 0, 'totalCount' => 0)); } if ($query->limit === null) { $query->limit = self::MAX_LIMIT; } $result = $this->locationSearchHandler->findLocations($query); foreach ($result->searchHits as $hit) { $hit->valueObject = $this->domainMapper->buildLocationDomainObject($hit->valueObject); } return $result; }