|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AOE\Crawler\Hooks; |
|
6
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
* (c) 2020 AOE GmbH <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* This file is part of the TYPO3 Crawler Extension. |
|
11
|
|
|
* |
|
12
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
13
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
14
|
|
|
* of the License, or any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* For the full copyright and license information, please read the |
|
17
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
18
|
|
|
* |
|
19
|
|
|
* The TYPO3 project - inspiring people to share! |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
use AOE\Crawler\Domain\Repository\QueueRepository; |
|
23
|
|
|
use AOE\Crawler\Service\QueueService; |
|
24
|
|
|
use TYPO3\CMS\Core\Domain\Repository\PageRepository; |
|
25
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
26
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
27
|
|
|
|
|
28
|
|
|
class DataHandlerHook |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @noRector \Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParameterRector |
|
32
|
|
|
*/ |
|
33
|
|
|
public function addFlushedPagesToCrawlerQueue(array $parameters, \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler): void |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
$pageIdsToBeFlushedFromCache = $parameters['pageIdArray']; |
|
36
|
|
|
if (empty($pageIdsToBeFlushedFromCache)) { |
|
37
|
|
|
return; |
|
38
|
|
|
} |
|
39
|
|
|
foreach ($pageIdsToBeFlushedFromCache as $pageId) { |
|
40
|
|
|
$pageId = (int) $pageId; |
|
41
|
|
|
if ($pageId < 1 || empty($this->getPageRepository()->getPage($pageId))) { |
|
42
|
|
|
continue; |
|
43
|
|
|
} |
|
44
|
|
|
if ($this->getQueueRepository()->isPageInQueue($pageId)) { |
|
45
|
|
|
continue; |
|
46
|
|
|
} |
|
47
|
|
|
$this->getQueueService()->addPageToQueue($pageId); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
private function getQueueRepository(): QueueRepository |
|
52
|
|
|
{ |
|
53
|
|
|
return GeneralUtility::makeInstance(ObjectManager::class)->get(QueueRepository::class); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
private function getQueueService(): QueueService |
|
57
|
|
|
{ |
|
58
|
|
|
return GeneralUtility::makeInstance(ObjectManager::class)->get(QueueService::class); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
private function getPageRepository() |
|
62
|
|
|
{ |
|
63
|
|
|
return GeneralUtility::makeInstance(PageRepository::class); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.