eZ\Publish\Core\Search\Elasticsearch\Content\Handler::indexLocation PHP Method

indexLocation() public method

Indexes a Location in the index storage.
public indexLocation ( eZ\Publish\SPI\Persistence\Content\Location $location )
$location eZ\Publish\SPI\Persistence\Content\Location
    public function indexLocation(Location $location)
    {
        $document = $this->mapper->mapLocation($location);
        $this->gateway->index($document);
    }

Usage Example

Example #1
0
 /**
  * Index Locations of the given Content Object.
  *
  * @param int $contentId Content Object Id
  * @param \Symfony\Component\Console\Helper\ProgressBar $progress
  */
 private function indexLocations($contentId, ProgressBar $progress)
 {
     $locationIds = $this->getContentLocationIds($contentId);
     foreach ($locationIds as $locationId) {
         try {
             $location = $this->persistenceHandler->locationHandler()->load($locationId);
             $this->searchHandler->indexLocation($location);
         } catch (NotFoundException $e) {
             $this->logWarning($progress, "Could not load Location with id {$locationId}, so skipped for indexing. Full exception: " . $e->getMessage());
         }
     }
 }