getResourceIterator(); $indexIterator = new IndexIterator($iterator); $indexIterator->setServiceLocator($this->getServiceLocator()); $searchService = $this->getServiceLocator()->get(Search::SERVICE_ID); $result = $searchService->index($indexIterator); $this->logDebug($result . ' resources have been indexed by ' . static::class); return $result; } /** * Returns a factory to get the IndexDocument Builder * * return IndexDocumentBuilderInterface */ public function getDocumentBuilder(): IndexDocumentBuilderInterface { return $this->getOption(self::OPTION_DOCUMENT_BUILDER); } /** * Create IndexDocument from core_kernel_classes_Resource * @param \core_kernel_classes_Resource $resource * @return IndexDocument * @throws \common_Exception * @throws \common_exception_InconsistentData * * @deprecated should be IndexDocumentBuilder::createDocumentFromResource instead */ public function createDocumentFromResource(\core_kernel_classes_Resource $resource): IndexDocument { /** @var IndexDocumentBuilder $documentBuilder */ $documentBuilder = $this->getDocumentBuilder(); $documentBuilder->setServiceLocator($this->getServiceLocator()); return $documentBuilder->createDocumentFromResource($resource); } /** * Create IndexDocument from array * @param array $array * @return IndexDocument * @throws \common_exception_MissingParameter * @throws \common_Exception * * @deprecated should be IndexDocumentBuilder::createDocumentFromArray instead */ public function createDocumentFromArray($array = []): IndexDocument { if (!isset($array['body'])) { throw new \common_exception_MissingParameter('body'); } if (!isset($array['id'])) { throw new \common_exception_MissingParameter('id'); } return $this->getDocumentBuilder()->createDocumentFromArray($array); } /** * @return \Iterator */ protected function getResourceIterator() { $iterator = new ResourceIterator($this->getIndexedClasses()); $iterator->setServiceLocator($this->getServiceLocator()); return $iterator; } protected function getIndexedClasses() { $classes = []; foreach (MenuService::getAllPerspectives() as $perspective) { foreach ($perspective->getChildren() as $structure) { foreach ($structure->getTrees() as $tree) { $rootNode = $tree->get('rootNode'); if (!empty($rootNode)) { $classes[$rootNode] = $this->getClass($rootNode); } } } } return array_values($classes); } }