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