indexIteratorFactory = $indexIteratorFactory; } /** * @throws common_exception_MissingParameter * @throws common_exception_Error */ public function __invoke($params): Report { if (empty($params) || empty($params[0])) { throw new common_exception_MissingParameter(); } /** @var SearchProxy $searchService */ $searchService = $this->getServiceLocator()->get(SearchProxy::SERVICE_ID); $numberOfIndexedResources = $searchService->index( $this->getIndexIteratorFactory()->create($params) ); $this->logInfo($numberOfIndexedResources . ' resources have been indexed by ' . static::class); $type = Report::TYPE_SUCCESS; $message = "Documents in index were successfully updated."; if ($numberOfIndexedResources < 1) { $type = Report::TYPE_INFO; $message = "Zero documents were added/updated in index."; } return new Report($type, $message); } private function getIndexIteratorFactory(): IndexIteratorFactory { if (null === $this->indexIteratorFactory) { $this->indexIteratorFactory = new IndexIteratorFactory($this->getServiceLocator()); } return $this->indexIteratorFactory; } }