@@ -6,21 +6,21 @@ |
||
6 | 6 | use Doctrine\ORM\EntityManagerInterface; |
7 | 7 | use Symfony\Component\HttpFoundation\RequestStack; |
8 | 8 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
9 | - AS Security; |
|
9 | + AS Security; |
|
10 | 10 | |
11 | 11 | class NotificationService |
12 | 12 | { |
13 | 13 | |
14 | - public function __construct( |
|
14 | + public function __construct( |
|
15 | 15 | private EntityManagerInterface $manager, |
16 | 16 | private Security $security, |
17 | 17 | private RequestStack $requestStack, |
18 | 18 | private PusherService $pusher |
19 | - ) { |
|
20 | - } |
|
19 | + ) { |
|
20 | + } |
|
21 | 21 | |
22 | - public function postPersist(Notification $notification) |
|
23 | - { |
|
22 | + public function postPersist(Notification $notification) |
|
23 | + { |
|
24 | 24 | $this->pusher->push(['company' => 1, 'people' => 1], 'my_topic'); |
25 | - } |
|
25 | + } |
|
26 | 26 | } |
@@ -13,37 +13,37 @@ |
||
13 | 13 | use Exception; |
14 | 14 | use Symfony\Component\HttpFoundation\JsonResponse; |
15 | 15 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
16 | - AS Security; |
|
16 | + AS Security; |
|
17 | 17 | |
18 | 18 | |
19 | 19 | |
20 | 20 | class AddAppConfigAction |
21 | 21 | { |
22 | - public function __construct( |
|
22 | + public function __construct( |
|
23 | 23 | private Security $security, |
24 | 24 | private EntityManagerInterface $manager, |
25 | 25 | private ConfigService $configService, |
26 | 26 | private HydratorService $hydratorService |
27 | - ) {} |
|
27 | + ) {} |
|
28 | 28 | |
29 | - public function __invoke(Request $request): JsonResponse |
|
30 | - { |
|
29 | + public function __invoke(Request $request): JsonResponse |
|
30 | + { |
|
31 | 31 | try { |
32 | - $json = json_decode($request->getContent(), true); |
|
33 | - $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
34 | - $module = $this->manager->getRepository(Module::class)->find(preg_replace("/[^0-9]/", "", $json['module'])); |
|
35 | - $configValue = json_decode($json['configValue'], true); |
|
36 | - $config = $this->configService->addConfig( |
|
32 | + $json = json_decode($request->getContent(), true); |
|
33 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
34 | + $module = $this->manager->getRepository(Module::class)->find(preg_replace("/[^0-9]/", "", $json['module'])); |
|
35 | + $configValue = json_decode($json['configValue'], true); |
|
36 | + $config = $this->configService->addConfig( |
|
37 | 37 | $people, |
38 | 38 | $json['configKey'], |
39 | 39 | $configValue, |
40 | 40 | $module, |
41 | 41 | $json['visibility'] |
42 | - ); |
|
42 | + ); |
|
43 | 43 | |
44 | - return new JsonResponse($this->hydratorService->item(Config::class, $config->getId(), "config:read"), Response::HTTP_OK); |
|
44 | + return new JsonResponse($this->hydratorService->item(Config::class, $config->getId(), "config:read"), Response::HTTP_OK); |
|
45 | 45 | } catch (Exception $e) { |
46 | - return new JsonResponse($this->hydratorService->error($e)); |
|
46 | + return new JsonResponse($this->hydratorService->error($e)); |
|
47 | + } |
|
47 | 48 | } |
48 | - } |
|
49 | 49 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class RouteRepository extends ServiceEntityRepository |
16 | 16 | { |
17 | - public function __construct(ManagerRegistry $registry) |
|
18 | - { |
|
17 | + public function __construct(ManagerRegistry $registry) |
|
18 | + { |
|
19 | 19 | parent::__construct($registry, Routes::class); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class MenuRepository extends ServiceEntityRepository |
16 | 16 | { |
17 | - public function __construct(ManagerRegistry $registry) |
|
18 | - { |
|
17 | + public function __construct(ManagerRegistry $registry) |
|
18 | + { |
|
19 | 19 | parent::__construct($registry, Menu::class); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -11,58 +11,58 @@ discard block |
||
11 | 11 | |
12 | 12 | class GetActionByPeopleAction |
13 | 13 | { |
14 | - private $manager = null; |
|
15 | - private $security = null; |
|
14 | + private $manager = null; |
|
15 | + private $security = null; |
|
16 | 16 | |
17 | - public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
18 | - { |
|
17 | + public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
18 | + { |
|
19 | 19 | $this->manager = $entityManager; |
20 | 20 | $this->security = $security; |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - public function __invoke(Request $request): JsonResponse |
|
24 | - { |
|
23 | + public function __invoke(Request $request): JsonResponse |
|
24 | + { |
|
25 | 25 | try { |
26 | - $menu = []; |
|
27 | - $company = $request->query->get('myCompany', null); |
|
26 | + $menu = []; |
|
27 | + $company = $request->query->get('myCompany', null); |
|
28 | 28 | |
29 | - if ($company === null) { |
|
29 | + if ($company === null) { |
|
30 | 30 | throw new Exception("Company not found", 404); |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - $myCompany = $this->manager->getRepository(People::class)->find($company); |
|
33 | + $myCompany = $this->manager->getRepository(People::class)->find($company); |
|
34 | 34 | |
35 | - if ($myCompany === null) { |
|
35 | + if ($myCompany === null) { |
|
36 | 36 | throw new Exception("Company not found", 404); |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - $currentUser = $this->security->getToken()->getUser(); |
|
40 | - $userPeople = $currentUser->getPeople(); |
|
39 | + $currentUser = $this->security->getToken()->getUser(); |
|
40 | + $userPeople = $currentUser->getPeople(); |
|
41 | 41 | |
42 | - $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
42 | + $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
43 | 43 | |
44 | - return new JsonResponse([ |
|
44 | + return new JsonResponse([ |
|
45 | 45 | 'response' => [ |
46 | - 'data' => $menu, |
|
47 | - 'count' => 1, |
|
48 | - 'error' => '', |
|
49 | - 'success' => true, |
|
46 | + 'data' => $menu, |
|
47 | + 'count' => 1, |
|
48 | + 'error' => '', |
|
49 | + 'success' => true, |
|
50 | 50 | ], |
51 | - ]); |
|
51 | + ]); |
|
52 | 52 | } catch (\Exception $e) { |
53 | - return new JsonResponse([ |
|
53 | + return new JsonResponse([ |
|
54 | 54 | 'response' => [ |
55 | - 'data' => [], |
|
56 | - 'count' => 0, |
|
57 | - 'error' => $e->getMessage(), |
|
58 | - 'success' => false, |
|
55 | + 'data' => [], |
|
56 | + 'count' => 0, |
|
57 | + 'error' => $e->getMessage(), |
|
58 | + 'success' => false, |
|
59 | 59 | ], |
60 | - ]); |
|
60 | + ]); |
|
61 | + } |
|
61 | 62 | } |
62 | - } |
|
63 | 63 | |
64 | - private function getMenuByPeople(People $userPeople, People $myCompany) |
|
65 | - { |
|
64 | + private function getMenuByPeople(People $userPeople, People $myCompany) |
|
65 | + { |
|
66 | 66 | $return = []; |
67 | 67 | $connection = $this->manager->getConnection(); |
68 | 68 | |
@@ -78,17 +78,17 @@ discard block |
||
78 | 78 | GROUP BY action.id'; |
79 | 79 | |
80 | 80 | $params = [ |
81 | - 'myCompany' => $myCompany->getId(), |
|
82 | - 'userPeople' => $userPeople->getId(), |
|
83 | - 'route' => $this->route, |
|
81 | + 'myCompany' => $myCompany->getId(), |
|
82 | + 'userPeople' => $userPeople->getId(), |
|
83 | + 'route' => $this->route, |
|
84 | 84 | ]; |
85 | 85 | |
86 | 86 | $result = $connection->executeQuery($sql, $params)->fetchAllAssociative(); |
87 | 87 | |
88 | 88 | foreach ($result as $action) { |
89 | - $return['routes'][trim($action['route'])]['actions'][$action['id']] = trim($action['action']); |
|
89 | + $return['routes'][trim($action['route'])]['actions'][$action['id']] = trim($action['action']); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $return; |
93 | - } |
|
93 | + } |
|
94 | 94 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | return $this; |
103 | 103 | } |
104 | 104 | |
105 | - public function getConfigs(bool $decode = false): string|array |
|
105 | + public function getConfigs(bool $decode = false): string | array |
|
106 | 106 | { |
107 | 107 | // Ensure we're decoding a string, even if it was temporarily an array internally |
108 | 108 | $configString = is_array($this->configs) ? json_encode($this->configs) : $this->configs; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return $this->setConfigs($configs); |
117 | 117 | } |
118 | 118 | |
119 | - public function setConfigs(string|array|object $configs): self |
|
119 | + public function setConfigs(string | array | object $configs): self |
|
120 | 120 | { |
121 | 121 | if (is_string($configs)) |
122 | 122 | $configs = json_decode($configs, true); |
@@ -118,8 +118,9 @@ |
||
118 | 118 | |
119 | 119 | public function setConfigs(string|array|object $configs): self |
120 | 120 | { |
121 | - if (is_string($configs)) |
|
122 | - $configs = json_decode($configs, true); |
|
121 | + if (is_string($configs)) { |
|
122 | + $configs = json_decode($configs, true); |
|
123 | + } |
|
123 | 124 | |
124 | 125 | $this->configs = json_encode($configs); |
125 | 126 | return $this; |