|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AOE\Crawler\Domain\Repository; |
|
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 TYPO3\CMS\Backend\Utility\BackendUtility; |
|
23
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryInterface; |
|
24
|
|
|
use TYPO3\CMS\Extbase\Persistence\Repository; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Class ConfigurationRepository |
|
28
|
|
|
*/ |
|
29
|
|
|
class ConfigurationRepository extends Repository |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface |
|
33
|
|
|
*/ |
|
34
|
1 |
|
public function getCrawlerConfigurationRecords() |
|
35
|
|
|
{ |
|
36
|
1 |
|
$query = $this->createQuery(); |
|
37
|
1 |
|
$query->getQuerySettings()->setRespectStoragePage(false); |
|
38
|
1 |
|
$query->getQuerySettings()->setIncludeDeleted(false); |
|
39
|
1 |
|
return $query->execute(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Traverses up the rootline of a page and fetches all crawler records. |
|
44
|
|
|
*/ |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param int $pageId |
|
48
|
|
|
* @return array|QueryInterface |
|
49
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException |
|
50
|
|
|
*/ |
|
51
|
5 |
|
public function getCrawlerConfigurationRecordsFromRootLine(int $pageId) |
|
52
|
|
|
{ |
|
53
|
5 |
|
$pageIdsInRootLine = []; |
|
54
|
5 |
|
$rootLine = BackendUtility::BEgetRootLine($pageId); |
|
55
|
|
|
|
|
56
|
5 |
|
foreach ($rootLine as $pageInRootLine) { |
|
57
|
4 |
|
$pageIdsInRootLine[] = (int) $pageInRootLine['uid']; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
5 |
|
if (empty($pageIdsInRootLine)) { |
|
61
|
1 |
|
return []; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
4 |
|
$query = $this->createQuery(); |
|
65
|
4 |
|
$query->getQuerySettings()->setRespectStoragePage(false); |
|
66
|
4 |
|
$query->getQuerySettings()->setIncludeDeleted(false); |
|
67
|
4 |
|
return $query->matching( |
|
|
|
|
|
|
68
|
4 |
|
$query->in('pid', $pageIdsInRootLine) |
|
69
|
4 |
|
)->execute(); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|