1
|
|
|
<?php |
2
|
|
|
namespace Aoe\FeatureFlag\Domain\Repository; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2021 AOE GmbH <[email protected]> |
8
|
|
|
* |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use Aoe\FeatureFlag\Domain\Model\Mapping; |
29
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
30
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
31
|
|
|
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; |
32
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; |
33
|
|
|
use TYPO3\CMS\Extbase\Persistence\Repository; |
34
|
|
|
|
35
|
|
|
class MappingRepository extends Repository |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function initializeObject() |
41
|
|
|
{ |
42
|
|
|
/** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */ |
43
|
|
|
$defaultQuerySettings = $this->objectManager->get(Typo3QuerySettings::class); |
|
|
|
|
44
|
|
|
$defaultQuerySettings->setRespectStoragePage(false); |
45
|
|
|
$defaultQuerySettings->setRespectSysLanguage(false); |
46
|
|
|
$defaultQuerySettings->setIgnoreEnableFields(false)->setIncludeDeleted(false); |
47
|
|
|
$this->setDefaultQuerySettings($defaultQuerySettings); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param int $foreignTableUid |
52
|
|
|
* @param string $foreignTableName |
53
|
|
|
* @return Mapping |
54
|
|
|
*/ |
55
|
|
|
public function findOneByForeignTableNameAndUid($foreignTableUid, $foreignTableName) |
56
|
|
|
{ |
57
|
|
|
return $this->findAllByForeignTableNameAndUid($foreignTableUid, $foreignTableName)->getFirst(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param int $foreignTableUid |
62
|
|
|
* @param string $foreignTableName |
63
|
|
|
* @return QueryResultInterface |
64
|
|
|
*/ |
65
|
|
|
public function findAllByForeignTableNameAndUid($foreignTableUid, $foreignTableName) |
66
|
|
|
{ |
67
|
|
|
$query = $this->createQuery(); |
68
|
|
|
$query->matching( |
69
|
|
|
$query->logicalAnd($query->equals('foreign_table_uid', $foreignTableUid), |
70
|
|
|
$query->equals('foreign_table_name', $foreignTableName)) |
|
|
|
|
71
|
|
|
); |
72
|
|
|
return $query->execute(); |
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param $featureFlagId |
77
|
|
|
* @return array|QueryResultInterface |
78
|
|
|
*/ |
79
|
|
|
public function findAllByFeatureFlag($featureFlagId) |
80
|
|
|
{ |
81
|
|
|
$query = $this->createQuery(); |
82
|
|
|
$query->getQuerySettings()->setRespectSysLanguage(false); |
83
|
|
|
$query->getQuerySettings()->setRespectStoragePage(false); |
84
|
|
|
$query->matching($query->equals('feature_flag', $featureFlagId)); |
85
|
|
|
return $query->execute(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return array |
90
|
|
|
*/ |
91
|
|
|
public function getHashedMappings() |
92
|
|
|
{ |
93
|
|
|
$mappings = $this->createQuery()->execute(true); |
94
|
|
|
$prepared = []; |
95
|
|
|
foreach ($mappings as $mapping) { |
96
|
|
|
$identifier = sha1($mapping['foreign_table_uid'] . '_' . $mapping['foreign_table_name']); |
97
|
|
|
$prepared[$identifier] = $identifier; |
98
|
|
|
} |
99
|
|
|
return $prepared; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
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.