Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Common/Indexer.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Search\Common;
8
9 use eZ\Publish\Core\Persistence\Database\DatabaseHandler;
10 use eZ\Publish\SPI\Persistence\Content\ContentInfo;
11 use eZ\Publish\SPI\Persistence\Handler as PersistenceHandler;
12 use eZ\Publish\SPI\Search\Handler as SearchHandler;
13 use Psr\Log\LoggerInterface;
14 use Symfony\Component\Console\Helper\ProgressBar;
15 use Symfony\Component\Console\Output\OutputInterface;
16 use PDO;
17
22 abstract class Indexer
23 {
24 const CONTENTOBJECT_TABLE = 'ezcontentobject';
25 const CONTENTOBJECT_TREE_TABLE = 'ezcontentobject_tree';
26
28 protected $logger;
29
31 protected $persistenceHandler;
32
34 protected $databaseHandler;
35
37 protected $searchHandler;
38
39 public function __construct(
40 LoggerInterface $logger,
41 PersistenceHandler $persistenceHandler,
42 DatabaseHandler $databaseHandler,
43 SearchHandler $searchHandler
44 ) {
45 $this->logger = $logger;
46 $this->persistenceHandler = $persistenceHandler;
47 $this->databaseHandler = $databaseHandler;
48 $this->searchHandler = $searchHandler;
49 }
50
58 abstract public function createSearchIndex(OutputInterface $output, $iterationCount, $commit);
59
67 protected function getContentDbFieldsStmt(array $fields)
68 {
69 $query = $this->databaseHandler->createSelectQuery();
70 $query->select($fields)
71 ->from($this->databaseHandler->quoteTable(self::CONTENTOBJECT_TABLE))
72 ->where($query->expr->eq('status', ContentInfo::STATUS_PUBLISHED));
73 $stmt = $query->prepare();
74 $stmt->execute();
75
76 return $stmt;
77 }
78
86 protected function getContentLocationIds($contentObjectId)
87 {
88 $query = $this->databaseHandler->createSelectQuery();
89 $query->select('node_id')
90 ->from($this->databaseHandler->quoteTable(self::CONTENTOBJECT_TREE_TABLE))
91 ->where($query->expr->eq('contentobject_id', $contentObjectId));
92 $stmt = $query->prepare();
93 $stmt->execute();
94 $nodeIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
95
96 return is_array($nodeIds) ? array_map('intval', $nodeIds) : [];
97 }
98
105 protected function logWarning(ProgressBar $progress, $message)
106 {
107 $progress->clear();
108 $this->logger->warning($message);
109 $progress->display();
110 }
111 }
eZ\Publish\Core\Search\Common\Indexer
Base class for the Search Engine Indexer Service aimed to recreate Search Engine Index.
Definition: Common/Indexer.php:23
eZ\Publish\Core\Search\Common\Indexer\createSearchIndex
createSearchIndex(OutputInterface $output, $iterationCount, $commit)
Create search engine index.
Definition: Elasticsearch/Content/Indexer.php:34
eZ\Publish\Core\Search\Common\Indexer\__construct
__construct(LoggerInterface $logger, PersistenceHandler $persistenceHandler, DatabaseHandler $databaseHandler, SearchHandler $searchHandler)
Definition: Common/Indexer.php:39
eZ\Publish\Core\Search\Common\Indexer\$databaseHandler
$databaseHandler
Definition: Common/Indexer.php:34
eZ\Publish\Core\Search\Common\Indexer\getContentDbFieldsStmt
getContentDbFieldsStmt(array $fields)
Get PDOStatement to fetch metadata about content objects to be indexed.
Definition: Common/Indexer.php:67
eZ\Publish\Core\Search\Common\Indexer\$logger
$logger
Definition: Common/Indexer.php:28
eZ\Publish\Core\Search\Common\Indexer\logWarning
logWarning(ProgressBar $progress, $message)
Log warning while progress bar is shown.
Definition: Common/Indexer.php:105
eZ\Publish\Core\Search\Common\Indexer\$searchHandler
$searchHandler
Definition: Common/Indexer.php:37
eZ\Publish\Core\Search\Common\Indexer\getContentLocationIds
getContentLocationIds($contentObjectId)
Fetch location Ids for the given content object.
Definition: Common/Indexer.php:86
eZ\Publish\Core\Search\Common\Indexer\$persistenceHandler
$persistenceHandler
Definition: Common/Indexer.php:31
eZ\Publish\Core\Search\Common\Indexer\CONTENTOBJECT_TABLE
const CONTENTOBJECT_TABLE
Definition: Common/Indexer.php:24
eZ\Publish\Core\Search\Common\Indexer\CONTENTOBJECT_TREE_TABLE
const CONTENTOBJECT_TREE_TABLE
Definition: Common/Indexer.php:25
eZ\Publish\SPI\Persistence\Content\ContentInfo
This class provides all version independent information of the content object.
Definition: SPI/Persistence/Content/ContentInfo.php:17
eZ\Publish\SPI\Persistence\Content\ContentInfo\STATUS_PUBLISHED
const STATUS_PUBLISHED
Definition: SPI/Persistence/Content/ContentInfo.php:19
eZ\Publish\Core\Persistence\Database\DatabaseHandler
Interface for relational database abstractions supported by eZ.
Definition: DatabaseHandler.php:18
eZ\Publish\SPI\Persistence\Handler
The main handler for Storage Engine.
Definition: SPI/Persistence/Handler.php:15
eZ\Publish\SPI\Search\Handler
The Search handler retrieves sets of of Content objects, based on a set of criteria.
Definition: SPI/Search/Handler.php:20
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.