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 | protected $dbHandler; |
||
37 | |||
38 | /** |
||
39 | * SPI Content Type Handler. |
||
40 | * |
||
41 | * Need this for being able to pick fields that are searchable. |
||
42 | * |
||
43 | * @var \eZ\Publish\SPI\Persistence\Content\Type\Handler |
||
44 | */ |
||
45 | protected $typeHandler; |
||
46 | |||
47 | /** |
||
48 | * Transformation processor. |
||
49 | * |
||
50 | * Need this for being able to transform text to searchable value |
||
51 | * |
||
52 | * @var \eZ\Publish\Core\Persistence\TransformationProcessor |
||
53 | */ |
||
54 | protected $transformationProcessor; |
||
55 | |||
56 | /** |
||
57 | * LegacySearchService. |
||
58 | * |
||
59 | * Need this for queries on ezsearch* tables |
||
60 | * |
||
61 | * @var \eZ\Publish\Core\Search\Legacy\Content\WordIndexer\Repository\SearchIndex |
||
62 | */ |
||
63 | protected $searchIndex; |
||
64 | |||
65 | /** |
||
66 | * Full text search configuration options. |
||
67 | * |
||
68 | * @var array |
||
69 | */ |
||
70 | protected $fullTextSearchConfiguration; |
||
71 | |||
72 | /** |
||
73 | * Construct from handler handler. |
||
74 | * |
||
75 | * @param \eZ\Publish\Core\Persistence\Database\DatabaseHandler $dbHandler |
||
76 | * @param \eZ\Publish\SPI\Persistence\Content\Type\Handler $typeHandler |
||
77 | * @param \eZ\Publish\Core\Persistence\TransformationProcessor $transformationProcessor |
||
78 | * @param \eZ\Publish\Core\Search\Legacy\Content\WordIndexer\Repository\SearchIndex $searchIndex |
||
79 | * @param array $fullTextSearchConfiguration |
||
80 | */ |
||
81 | public function __construct( |
||
94 | |||
95 | /** |
||
96 | * Index search engine full text data corresponding to content object field values. |
||
97 | * |
||
98 | * Ported from the legacy code |
||
99 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L45 |
||
100 | * |
||
101 | * @param \eZ\Publish\Core\Search\Legacy\Content\FullTextData $fullTextData |
||
102 | */ |
||
103 | public function index(FullTextData $fullTextData) |
||
164 | |||
165 | /** |
||
166 | * Indexes an array of FullTextData objects. |
||
167 | * |
||
168 | * Note: on large amounts of data make sure to iterate with several calls to this function with |
||
169 | * a limited set of FullTextData objects. Amount you have memory for depends on server, size |
||
170 | * of FullTextData objects & PHP version. |
||
171 | * |
||
172 | * @param \eZ\Publish\Core\Search\Legacy\Content\FullTextData[] $fullTextBulkData |
||
173 | */ |
||
174 | public function bulkIndex(array $fullTextBulkData) |
||
180 | |||
181 | /** |
||
182 | * Remove whole content or a specific version from index. |
||
183 | * |
||
184 | * Ported from the legacy code |
||
185 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L386 |
||
186 | * |
||
187 | * @param mixed $contentId |
||
188 | * @param mixed|null $versionId |
||
189 | * |
||
190 | * @return bool |
||
191 | */ |
||
192 | public function remove($contentId, $versionId = null) |
||
210 | |||
211 | /** |
||
212 | * Remove entire search index. |
||
213 | */ |
||
214 | public function purgeIndex() |
||
218 | |||
219 | /** |
||
220 | * Index wordIndex. |
||
221 | * |
||
222 | * Ported from the legacy code |
||
223 | * |
||
224 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L255 |
||
225 | * |
||
226 | * @param \eZ\Publish\Core\Search\Legacy\Content\FullTextData $fullTextData |
||
227 | * @param array $indexArray |
||
228 | * @param array $wordIDArray |
||
229 | * @param int $placement |
||
230 | * |
||
231 | * @return int last placement |
||
232 | */ |
||
233 | private function indexWords(FullTextData $fullTextData, array $indexArray, array $wordIDArray, $placement = 0) |
||
260 | |||
261 | /** |
||
262 | * Build WordIDArray and update ezsearch_word table. |
||
263 | * |
||
264 | * Ported from the legacy code |
||
265 | * |
||
266 | * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L155 |
||
267 | * |
||
268 | * @param array $indexArrayOnlyWords words for object to add |
||
269 | * |
||
270 | * @return array wordIDArray |
||
271 | */ |
||
272 | private function buildWordIDArray(array $indexArrayOnlyWords) |
||
315 | } |
||
316 |
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: