1 | <?php |
||
22 | class DoctrineDatabase extends Gateway |
||
23 | { |
||
24 | /** |
||
25 | * Max acceptable by any DBMS INT value. |
||
26 | * |
||
27 | * Note: 2^31-1 seems to be the most reasonable value that should work in any setup. |
||
28 | */ |
||
29 | const DB_INT_MAX = 2147483647; |
||
30 | |||
31 | /** |
||
32 | * Database handler. |
||
33 | * |
||
34 | * @var \eZ\Publish\Core\Persistence\Database\DatabaseHandler |
||
35 | * |
||
36 | * @deprecated Start to use DBAL $connection instead. |
||
37 | */ |
||
38 | protected $dbHandler; |
||
39 | |||
40 | /** |
||
41 | * SPI Content Type Handler. |
||
42 | * |
||
43 | * Need this for being able to pick fields that are searchable. |
||
44 | * |
||
45 | * @var \eZ\Publish\SPI\Persistence\Content\Type\Handler |
||
46 | */ |
||
47 | protected $typeHandler; |
||
48 | |||
49 | /** |
||
50 | * Transformation processor. |
||
51 | * |
||
52 | * Need this for being able to transform text to searchable value |
||
53 | * |
||
54 | * @var \eZ\Publish\Core\Persistence\TransformationProcessor |
||
55 | */ |
||
56 | protected $transformationProcessor; |
||
57 | |||
58 | /** |
||
59 | * LegacySearchService. |
||
60 | * |
||
61 | * Need this for queries on ezsearch* tables |
||
62 | * |
||
63 | * @var \eZ\Publish\Core\Search\Legacy\Content\WordIndexer\Repository\SearchIndex |
||
64 | */ |
||
65 | protected $searchIndex; |
||
66 | |||
67 | /** @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator */ |
||
68 | private $languageMaskGenerator; |
||
69 | |||
70 | /** |
||
71 | * Full text search configuration options. |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | protected $fullTextSearchConfiguration; |
||
76 | |||
77 | /** |
||
78 | * Construct from handler handler. |
||
79 | * |
||
80 | * @param \eZ\Publish\Core\Persistence\Database\DatabaseHandler $dbHandler |
||
81 | * @param \eZ\Publish\SPI\Persistence\Content\Type\Handler $typeHandler |
||
82 | * @param \eZ\Publish\Core\Persistence\TransformationProcessor $transformationProcessor |
||
83 | * @param \eZ\Publish\Core\Search\Legacy\Content\WordIndexer\Repository\SearchIndex $searchIndex |
||
84 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator $languageMaskGenerator |
||
85 | * @param array $fullTextSearchConfiguration |
||
86 | */ |
||
87 | public function __construct( |
||
102 | |||
103 | /** |
||
104 | * Index search engine full text data corresponding to content object field values. |
||
105 | * |
||
106 | * Ported from the legacy code |
||
107 | * |
||
108 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L45 |
||
109 | * |
||
110 | * @param \eZ\Publish\Core\Search\Legacy\Content\FullTextData $fullTextData |
||
111 | */ |
||
112 | public function index(FullTextData $fullTextData) |
||
187 | |||
188 | /** |
||
189 | * Indexes an array of FullTextData objects. |
||
190 | * |
||
191 | * Note: on large amounts of data make sure to iterate with several calls to this function with |
||
192 | * a limited set of FullTextData objects. Amount you have memory for depends on server, size |
||
193 | * of FullTextData objects & PHP version. |
||
194 | * |
||
195 | * @param \eZ\Publish\Core\Search\Legacy\Content\FullTextData[] $fullTextBulkData |
||
196 | */ |
||
197 | public function bulkIndex(array $fullTextBulkData) |
||
203 | |||
204 | /** |
||
205 | * Remove whole content or a specific version from index. |
||
206 | * |
||
207 | * Ported from the legacy code |
||
208 | * |
||
209 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L386 |
||
210 | * |
||
211 | * @param mixed $contentId |
||
212 | * @param mixed|null $versionId |
||
213 | * |
||
214 | * @return bool |
||
215 | */ |
||
216 | public function remove($contentId, $versionId = null) |
||
234 | |||
235 | /** |
||
236 | * Remove entire search index. |
||
237 | */ |
||
238 | public function purgeIndex() |
||
242 | |||
243 | /** |
||
244 | * Index wordIndex. |
||
245 | * |
||
246 | * Ported from the legacy code |
||
247 | * |
||
248 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L255 |
||
249 | * |
||
250 | * @param \eZ\Publish\Core\Search\Legacy\Content\FullTextData $fullTextData |
||
251 | * @param array $indexArray |
||
252 | * @param array $wordIDArray |
||
253 | * @param int $placement |
||
254 | * |
||
255 | * @return int last placement |
||
256 | */ |
||
257 | private function indexWords(FullTextData $fullTextData, array $indexArray, array $wordIDArray, $placement = 0) |
||
304 | |||
305 | /** |
||
306 | * Build WordIDArray and update ezsearch_word table. |
||
307 | * |
||
308 | * Ported from the legacy code |
||
309 | * |
||
310 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L155 |
||
311 | * |
||
312 | * @param array $indexArrayOnlyWords words for object to add |
||
313 | * |
||
314 | * @return array wordIDArray |
||
315 | */ |
||
316 | private function buildWordIDArray(array $indexArrayOnlyWords) |
||
359 | } |
||
360 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: