1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the |
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace DERHANSEN\SfEventMgt\Domain\Repository; |
13
|
|
|
|
14
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Category; |
15
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\CategoryDemand; |
16
|
|
|
use DERHANSEN\SfEventMgt\Service\CategoryService; |
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
18
|
|
|
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; |
|
|
|
|
19
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryInterface; |
|
|
|
|
20
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; |
|
|
|
|
21
|
|
|
use TYPO3\CMS\Extbase\Persistence\Repository; |
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @extends Repository<Category> |
25
|
|
|
*/ |
26
|
|
|
class CategoryRepository extends Repository |
27
|
|
|
{ |
28
|
|
|
public function initializeObject(): void |
29
|
|
|
{ |
30
|
|
|
$this->defaultQuerySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); |
|
|
|
|
31
|
|
|
$this->defaultQuerySettings->setRespectStoragePage(false); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Returns all categories depending on the settings in the demand object |
36
|
|
|
*/ |
37
|
|
|
public function findDemanded(CategoryDemand $demand): QueryResultInterface |
38
|
|
|
{ |
39
|
|
|
$constraints = []; |
40
|
|
|
$query = $this->createQuery(); |
41
|
|
|
|
42
|
|
|
if ($demand->getCategories() !== '') { |
43
|
|
|
$query->getQuerySettings()->setRespectSysLanguage(false); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if ($demand->getRestrictToStoragePage()) { |
47
|
|
|
$pidList = GeneralUtility::intExplode(',', $demand->getStoragePage(), true); |
48
|
|
|
$constraints[] = $query->in('pid', $pidList); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if ($demand->getCategories()) { |
52
|
|
|
if ($demand->getIncludeSubcategories()) { |
53
|
|
|
$categoryList = CategoryService::getCategoryListWithChilds($demand->getCategories()); |
54
|
|
|
$pidList = GeneralUtility::intExplode(',', $categoryList, true); |
55
|
|
|
} else { |
56
|
|
|
$pidList = GeneralUtility::intExplode(',', $demand->getCategories(), true); |
57
|
|
|
} |
58
|
|
|
$constraints[] = $query->in('uid', $pidList); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if (count($constraints) > 0) { |
62
|
|
|
$query->matching($query->logicalAnd(...$constraints)); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if ($demand->getOrderField() !== '' && $demand->getOrderDirection() !== '' && |
66
|
|
|
in_array($demand->getOrderField(), CategoryDemand::ORDER_FIELD_ALLOWED, true) |
67
|
|
|
) { |
68
|
|
|
$orderings[$demand->getOrderField()] = ((strtolower($demand->getOrderDirection()) === 'desc') ? |
|
|
|
|
69
|
|
|
QueryInterface::ORDER_DESCENDING : |
70
|
|
|
QueryInterface::ORDER_ASCENDING); |
71
|
|
|
$query->setOrderings($orderings); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return $query->execute(); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths