|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Repository; |
|
4
|
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Config; |
|
6
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
|
|
7
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
|
|
|
|
|
8
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @method Config|null find($id, $lockMode = null, $lockVersion = null) |
|
12
|
|
|
* @method Config|null findOneBy(array $criteria, array $orderBy = null) |
|
13
|
|
|
* @method Config[] findAll() |
|
14
|
|
|
* @method Config[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
15
|
|
|
*/ |
|
16
|
|
|
class ConfigRepository extends ServiceEntityRepository |
|
17
|
|
|
{ |
|
18
|
|
|
public function __construct(ManagerRegistry $registry) |
|
19
|
|
|
{ |
|
20
|
|
|
parent::__construct($registry, Config::class); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function updatePeopleConfigKey(People $people, string $key, string $value): void |
|
24
|
|
|
{ |
|
25
|
|
|
try { |
|
26
|
|
|
$params = []; |
|
27
|
|
|
|
|
28
|
|
|
$this->getEntityManager()->getConnection() |
|
29
|
|
|
->executeQuery('START TRANSACTION', $params); |
|
30
|
|
|
|
|
31
|
|
|
$rawSQL = <<<SQL |
|
32
|
|
|
UPDATE config |
|
33
|
|
|
SET configValue = :value |
|
34
|
|
|
WHERE people_id = :id AND configKey = :key |
|
35
|
|
|
SQL; |
|
36
|
|
|
|
|
37
|
|
|
$params = [ |
|
38
|
|
|
'id' => $people->getId(), |
|
39
|
|
|
'key' => $key, |
|
40
|
|
|
'value' => $value, |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
$this->getEntityManager()->getConnection() |
|
44
|
|
|
->executeQuery($rawSQL, $params); |
|
45
|
|
|
|
|
46
|
|
|
$this->getEntityManager()->getConnection() |
|
47
|
|
|
->executeQuery('COMMIT', $params); |
|
48
|
|
|
} catch (\Exception $e) { |
|
49
|
|
|
$this->getEntityManager()->getConnection() |
|
50
|
|
|
->executeQuery('ROLLBACK', $params); |
|
51
|
|
|
|
|
52
|
|
|
throw new \Exception($e->getMessage()); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getKeyValuesByPeople(People $people, string $key): ?array |
|
57
|
|
|
{ |
|
58
|
|
|
$result = $this->createQueryBuilder('a') |
|
59
|
|
|
->andWhere('a.people = :people') |
|
60
|
|
|
->andWhere('a.configKey LIKE :prefix') |
|
61
|
|
|
->setParameter('people', $people) |
|
62
|
|
|
->setParameter('prefix', $key . '-%') |
|
63
|
|
|
|
|
64
|
|
|
->getQuery() |
|
65
|
|
|
->getResult(); |
|
66
|
|
|
|
|
67
|
|
|
if (empty($result)) |
|
68
|
|
|
return null; |
|
69
|
|
|
|
|
70
|
|
|
$configs = []; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var Config $config |
|
74
|
|
|
*/ |
|
75
|
|
|
foreach ($result as $config) { |
|
76
|
|
|
$configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $configs; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getItauConfigByPeople(People $people): ?array |
|
83
|
|
|
{ |
|
84
|
|
|
|
|
85
|
|
|
$config = $this->getEntityManager()->getRepository(Config::class)->findOneBy([ |
|
86
|
|
|
'people' => $people, |
|
87
|
|
|
'configKey' => 'payment_type' |
|
88
|
|
|
]); |
|
89
|
|
|
|
|
90
|
|
|
|
|
91
|
|
|
if (empty($config) || $config->getConfigValue() != 'itau') |
|
92
|
|
|
return null; |
|
93
|
|
|
|
|
94
|
|
|
$result = $this->createQueryBuilder('a') |
|
95
|
|
|
->andWhere('a.people = :people') |
|
96
|
|
|
->andWhere('a.configKey LIKE :prefix') |
|
97
|
|
|
->setParameter('people', $people) |
|
98
|
|
|
->setParameter('prefix', 'itau-shopline-%') |
|
99
|
|
|
->getQuery() |
|
100
|
|
|
->getResult(); |
|
101
|
|
|
|
|
102
|
|
|
if (empty($result)) |
|
103
|
|
|
return null; |
|
104
|
|
|
|
|
105
|
|
|
$configs = []; |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @var Config $config |
|
109
|
|
|
*/ |
|
110
|
|
|
foreach ($result as $config) { |
|
111
|
|
|
$configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
return $configs; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function getMauticConfigByPeople(People $people): ?array |
|
118
|
|
|
{ |
|
119
|
|
|
$result = $this->createQueryBuilder('a') |
|
120
|
|
|
->andWhere('a.people = :people') |
|
121
|
|
|
->andWhere('a.configKey LIKE :prefix') |
|
122
|
|
|
->setParameter('people', $people) |
|
123
|
|
|
->setParameter('prefix', 'mautic-%') |
|
124
|
|
|
|
|
125
|
|
|
->getQuery() |
|
126
|
|
|
->getResult(); |
|
127
|
|
|
|
|
128
|
|
|
if (empty($result)) |
|
129
|
|
|
return null; |
|
130
|
|
|
|
|
131
|
|
|
$configs = []; |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @var Config $config |
|
135
|
|
|
*/ |
|
136
|
|
|
foreach ($result as $config) { |
|
137
|
|
|
$configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
return $configs; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|
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