|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the eZ Publish Kernel package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\Core\Search\Legacy\Content; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Exceptions\NotFoundException; |
|
12
|
|
|
use eZ\Publish\Core\Persistence\Database\DatabaseHandler; |
|
13
|
|
|
use eZ\Publish\Core\Search\Common\IncrementalIndexer; |
|
14
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Handler as LegacySearchHandler; |
|
15
|
|
|
use eZ\Publish\SPI\Persistence\Handler as PersistenceHandler; |
|
16
|
|
|
use Psr\Log\LoggerInterface; |
|
17
|
|
|
|
|
18
|
|
|
class Indexer extends IncrementalIndexer |
|
19
|
|
|
{ |
|
20
|
|
|
public function __construct( |
|
21
|
|
|
LoggerInterface $logger, |
|
22
|
|
|
PersistenceHandler $persistenceHandler, |
|
23
|
|
|
DatabaseHandler $databaseHandler, |
|
24
|
|
|
LegacySearchHandler $searchHandler |
|
25
|
|
|
) { |
|
26
|
|
|
parent::__construct($logger, $persistenceHandler, $databaseHandler, $searchHandler); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function getName() |
|
30
|
|
|
{ |
|
31
|
|
|
return 'eZ Platform Legacy (SQL) Search Engine'; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function updateSearchIndex(array $contentIds, $commit) |
|
35
|
|
|
{ |
|
36
|
|
|
$contentHandler = $this->persistenceHandler->contentHandler(); |
|
37
|
|
|
foreach ($contentIds as $contentId) { |
|
38
|
|
|
try { |
|
39
|
|
|
$info = $contentHandler->loadContentInfo($contentId); |
|
40
|
|
|
if ($info->isPublished) { |
|
41
|
|
|
$this->searchHandler->indexContent( |
|
42
|
|
|
$contentHandler->load($info->id, $info->currentVersionNo) |
|
43
|
|
|
); |
|
44
|
|
|
} else { |
|
45
|
|
|
$this->searchHandler->deleteContent($contentId); |
|
46
|
|
|
} |
|
47
|
|
|
} catch (NotFoundException $e) { |
|
48
|
|
|
$this->searchHandler->deleteContent($contentId); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function purge() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->searchHandler->purgeIndex(); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|