@@ -51,8 +51,9 @@ |
||
51 | 51 | $service = $this->container->get($serviceName); |
52 | 52 | if (method_exists($service, $method)) { |
53 | 53 | $entity = $service->$method($entity); |
54 | - if ('afterPersist' === $method && $entity) |
|
55 | - $this->manager->refresh($entity); |
|
54 | + if ('afterPersist' === $method && $entity) { |
|
55 | + $this->manager->refresh($entity); |
|
56 | + } |
|
56 | 57 | } |
57 | 58 | } |
58 | 59 | } |
@@ -38,8 +38,9 @@ |
||
38 | 38 | ) |
39 | 39 | )); |
40 | 40 | |
41 | - if (!$domain) |
|
42 | - throw new InvalidArgumentException('Please define header or get param "app-domain"', 301); |
|
41 | + if (!$domain) { |
|
42 | + throw new InvalidArgumentException('Please define header or get param "app-domain"', 301); |
|
43 | + } |
|
43 | 44 | return $domain; |
44 | 45 | } |
45 | 46 |
@@ -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 config_value = :value |
34 | 34 | WHERE people_id = :id AND config_key = :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.config_key LIKE :prefix') |
|
61 | - ->setParameter('people', $people) |
|
62 | - ->setParameter('prefix', $key . '-%') |
|
59 | + ->andWhere('a.people = :people') |
|
60 | + ->andWhere('a.config_key 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 | - 'config_key' => 'payment_type' |
|
86 | + 'people' => $people, |
|
87 | + 'config_key' => '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.config_key LIKE :prefix') |
|
97 | - ->setParameter('people', $people) |
|
98 | - ->setParameter('prefix', 'itau-shopline-%') |
|
99 | - ->getQuery() |
|
100 | - ->getResult(); |
|
95 | + ->andWhere('a.people = :people') |
|
96 | + ->andWhere('a.config_key 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.config_key LIKE :prefix') |
|
122 | - ->setParameter('people', $people) |
|
123 | - ->setParameter('prefix', 'mautic-%') |
|
120 | + ->andWhere('a.people = :people') |
|
121 | + ->andWhere('a.config_key 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 | } |
@@ -64,8 +64,9 @@ discard block |
||
64 | 64 | ->getQuery() |
65 | 65 | ->getResult(); |
66 | 66 | |
67 | - if (empty($result)) |
|
68 | - return null; |
|
67 | + if (empty($result)) { |
|
68 | + return null; |
|
69 | + } |
|
69 | 70 | |
70 | 71 | $configs = []; |
71 | 72 | |
@@ -88,8 +89,9 @@ discard block |
||
88 | 89 | ]); |
89 | 90 | |
90 | 91 | |
91 | - if (empty($config) || $config->getConfigValue() != 'itau') |
|
92 | - return null; |
|
92 | + if (empty($config) || $config->getConfigValue() != 'itau') { |
|
93 | + return null; |
|
94 | + } |
|
93 | 95 | |
94 | 96 | $result = $this->createQueryBuilder('a') |
95 | 97 | ->andWhere('a.people = :people') |
@@ -99,8 +101,9 @@ discard block |
||
99 | 101 | ->getQuery() |
100 | 102 | ->getResult(); |
101 | 103 | |
102 | - if (empty($result)) |
|
103 | - return null; |
|
104 | + if (empty($result)) { |
|
105 | + return null; |
|
106 | + } |
|
104 | 107 | |
105 | 108 | $configs = []; |
106 | 109 | |
@@ -125,8 +128,9 @@ discard block |
||
125 | 128 | ->getQuery() |
126 | 129 | ->getResult(); |
127 | 130 | |
128 | - if (empty($result)) |
|
129 | - return null; |
|
131 | + if (empty($result)) { |
|
132 | + return null; |
|
133 | + } |
|
130 | 134 | |
131 | 135 | $configs = []; |
132 | 136 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return; |
29 | 29 | self::$persisted = true; |
30 | 30 | |
31 | - $json = json_decode($this->request->getContent(), true); |
|
31 | + $json = json_decode($this->request->getContent(), true); |
|
32 | 32 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
33 | 33 | |
34 | 34 | if (!$extra_data) |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | if (!$entity_id || !$entity_name) |
47 | 47 | return; |
48 | - $json = json_decode($this->request->getContent(), true); |
|
48 | + $json = json_decode($this->request->getContent(), true); |
|
49 | 49 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
50 | 50 | |
51 | 51 | if (!$extra_data) |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | if (self::$persisted == true) |
81 | 81 | return; |
82 | 82 | self::$persisted = true; |
83 | - $json = json_decode($this->request->getContent(), true); |
|
83 | + $json = json_decode($this->request->getContent(), true); |
|
84 | 84 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
85 | 85 | if (!$extra_data) |
86 | 86 | return; |
@@ -24,15 +24,17 @@ discard block |
||
24 | 24 | } |
25 | 25 | public function persist($entity) |
26 | 26 | { |
27 | - if (self::$persisted == true) |
|
28 | - return; |
|
27 | + if (self::$persisted == true) { |
|
28 | + return; |
|
29 | + } |
|
29 | 30 | self::$persisted = true; |
30 | 31 | |
31 | 32 | $json = json_decode($this->request->getContent(), true); |
32 | 33 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
33 | 34 | |
34 | - if (!$extra_data) |
|
35 | - return; |
|
35 | + if (!$extra_data) { |
|
36 | + return; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | //$this->manager->persist($entity); |
38 | 40 | //$this->manager->flush(); |
@@ -43,13 +45,15 @@ discard block |
||
43 | 45 | } |
44 | 46 | private function persistData($entity_id, $entity_name) |
45 | 47 | { |
46 | - if (!$entity_id || !$entity_name) |
|
47 | - return; |
|
48 | + if (!$entity_id || !$entity_name) { |
|
49 | + return; |
|
50 | + } |
|
48 | 51 | $json = json_decode($this->request->getContent(), true); |
49 | 52 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
50 | 53 | |
51 | - if (!$extra_data) |
|
52 | - return; |
|
54 | + if (!$extra_data) { |
|
55 | + return; |
|
56 | + } |
|
53 | 57 | |
54 | 58 | |
55 | 59 | foreach ($extra_data['data'] as $key => $data) { |
@@ -61,8 +65,9 @@ discard block |
||
61 | 65 | 'extra_fields' => $extra_fields |
62 | 66 | ]); |
63 | 67 | |
64 | - if (!$extraData) |
|
65 | - $extraData = new ExtraData(); |
|
68 | + if (!$extraData) { |
|
69 | + $extraData = new ExtraData(); |
|
70 | + } |
|
66 | 71 | |
67 | 72 | $extraData->setExtraFields($extra_fields); |
68 | 73 | $extraData->setEntityName($entity_name); |
@@ -77,13 +82,15 @@ discard block |
||
77 | 82 | |
78 | 83 | public function noChange() |
79 | 84 | { |
80 | - if (self::$persisted == true) |
|
81 | - return; |
|
85 | + if (self::$persisted == true) { |
|
86 | + return; |
|
87 | + } |
|
82 | 88 | self::$persisted = true; |
83 | 89 | $json = json_decode($this->request->getContent(), true); |
84 | 90 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
85 | - if (!$extra_data) |
|
86 | - return; |
|
91 | + if (!$extra_data) { |
|
92 | + return; |
|
93 | + } |
|
87 | 94 | |
88 | 95 | $this->persistData($extra_data['entity_id'], $extra_data['entity_name']); |
89 | 96 | } |
@@ -10,16 +10,16 @@ |
||
10 | 10 | class NotificationService |
11 | 11 | { |
12 | 12 | |
13 | - public function __construct( |
|
13 | + public function __construct( |
|
14 | 14 | private EntityManagerInterface $manager, |
15 | 15 | private Security $security, |
16 | 16 | private RequestStack $requestStack, |
17 | 17 | private PusherService $pusher |
18 | - ) { |
|
19 | - } |
|
18 | + ) { |
|
19 | + } |
|
20 | 20 | |
21 | - public function afterPersist(Notification $notification) |
|
22 | - { |
|
21 | + public function afterPersist(Notification $notification) |
|
22 | + { |
|
23 | 23 | $this->pusher->push(['company' => 1, 'people' => 1], 'my_topic'); |
24 | - } |
|
24 | + } |
|
25 | 25 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | { |
19 | 19 | try { |
20 | 20 | $this->logger->info('Attempting to push message', ['data' => $data, 'topic' => $topic]); |
21 | - $webSocketClient = new Client('localhost', '8080'); |
|
21 | + $webSocketClient = new Client('localhost', '8080'); |
|
22 | 22 | $webSocketClient->connect(); |
23 | 23 | $webSocketClient->publish($topic, json_encode($data)); |
24 | 24 | $webSocketClient->disconnect(); |