/** * Adds object $contentObject to the search database. * * @param \eZContentObject $contentObject Object to add to search engine * @param bool $commit Whether to commit after adding the object * * @return bool True if the operation succeeded. */ public function addObject($contentObject, $commit = true) { // Indexing is not implemented in eZ Publish 5 legacy search engine if ($this->searchHandler instanceof LegacyHandler) { $searchEngine = new eZSearchEngine(); $searchEngine->addObject($contentObject, $commit); return true; } try { // If the method is called for restoring from trash we'll be inside a transaction, // meaning created Location(s) will not be visible outside of it. // We check that Content's Locations are visible from the new stack, if not Content // will be registered for indexing. foreach ($contentObject->assignedNodes() as $node) { $this->persistenceHandler->locationHandler()->load($node->attribute('node_id')); } $content = $this->persistenceHandler->contentHandler()->load((int) $contentObject->attribute('id'), (int) $contentObject->attribute('current_version')); } catch (NotFoundException $e) { $pendingAction = new eZPendingActions(array('action' => 'index_object', 'created' => time(), 'param' => (int) $contentObject->attribute('id'))); $pendingAction->store(); return true; } $this->searchHandler->indexContent($content); if ($commit) { $this->commit(); } return true; }
/** * Adds object $contentObject to the search database. * * @param \eZContentObject $contentObject Object to add to search engine * @param bool $commit Whether to commit after adding the object * * @return bool True if the operation succeeded. */ public function addObject($contentObject, $commit = true) { // Indexing is not implemented in eZ Publish 5 legacy search engine if ($this->searchEngine == 'legacy') { $searchEngine = new eZSearchEngine(); $searchEngine->addObject($contentObject, $commit); } else { $content = $this->persistenceHandler->contentHandler()->load((int) $contentObject->attribute('id'), (int) $contentObject->attribute('current_version')); $this->searchHandler->indexContent($content); } if ($commit) { $this->commit(); } return true; }