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\Core\Database\Connection; |
||||
24 | use TYPO3\CMS\Core\Database\ConnectionPool; |
||||
25 | use TYPO3\CMS\Core\Database\Query\QueryBuilder; |
||||
26 | use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; |
||||
27 | use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; |
||||
28 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
||||
29 | use TYPO3\CMS\Extbase\Persistence\Repository; |
||||
30 | |||||
31 | /** |
||||
32 | * @internal since v9.2.5 |
||||
33 | */ |
||||
34 | class ConfigurationRepository extends Repository |
||||
35 | { |
||||
36 | public const TABLE_NAME = 'tx_crawler_configuration'; |
||||
37 | |||||
38 | 1 | public function getCrawlerConfigurationRecords(): array |
|||
39 | { |
||||
40 | 1 | $records = []; |
|||
41 | 1 | $queryBuilder = $this->createQueryBuilder(); |
|||
42 | $statement = $queryBuilder |
||||
43 | 1 | ->select('*') |
|||
44 | 1 | ->from(self::TABLE_NAME) |
|||
45 | 1 | ->execute(); |
|||
46 | |||||
47 | 1 | while ($row = $statement->fetch()) { |
|||
0 ignored issues
–
show
|
|||||
48 | 1 | $records[] = $row; |
|||
49 | } |
||||
50 | |||||
51 | 1 | return $records; |
|||
52 | } |
||||
53 | |||||
54 | /** |
||||
55 | * Traverses up the rootline of a page and fetches all crawler records. |
||||
56 | */ |
||||
57 | 11 | public function getCrawlerConfigurationRecordsFromRootLine(int $pageId, array $parentIds = []): array |
|||
58 | { |
||||
59 | 11 | if (empty($parentIds)) { |
|||
60 | 10 | $pageIdsInRootLine = []; |
|||
61 | 10 | $rootLine = BackendUtility::BEgetRootLine($pageId); |
|||
62 | |||||
63 | 10 | foreach ($rootLine as $pageInRootLine) { |
|||
64 | 8 | $pageIdsInRootLine[] = (int) $pageInRootLine['uid']; |
|||
65 | } |
||||
66 | } else { |
||||
67 | 1 | $pageIdsInRootLine = $parentIds; |
|||
68 | } |
||||
69 | |||||
70 | 11 | $queryBuilder = $this->createQueryBuilder(); |
|||
71 | $queryBuilder |
||||
72 | 11 | ->getRestrictions()->removeAll() |
|||
73 | 11 | ->add(GeneralUtility::makeInstance(DeletedRestriction::class)) |
|||
74 | 11 | ->add(GeneralUtility::makeInstance(HiddenRestriction::class)); |
|||
75 | $configurationRecordsForCurrentPage = $queryBuilder |
||||
0 ignored issues
–
show
The function
Doctrine\DBAL\ForwardCom...lity\Result::fetchAll() has been deprecated: Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||
76 | 11 | ->select('*') |
|||
77 | 11 | ->from(self::TABLE_NAME) |
|||
78 | 11 | ->where( |
|||
79 | 11 | $queryBuilder->expr()->in('pid', $queryBuilder->createNamedParameter($pageIdsInRootLine, Connection::PARAM_INT_ARRAY)) |
|||
80 | ) |
||||
81 | 11 | ->execute() |
|||
82 | 11 | ->fetchAll(); |
|||
83 | 11 | return is_array($configurationRecordsForCurrentPage) ? $configurationRecordsForCurrentPage : []; |
|||
0 ignored issues
–
show
|
|||||
84 | } |
||||
85 | |||||
86 | 12 | protected function createQueryBuilder(): QueryBuilder |
|||
87 | { |
||||
88 | 12 | return GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE_NAME); |
|||
89 | } |
||||
90 | } |
||||
91 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.