@@ -7,7 +7,7 @@ |
||
7 | 7 | use ControleOnline\Entity\ExtraData; |
8 | 8 | use ControleOnline\Entity\ExtraFields; |
9 | 9 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
10 | - AS Security; |
|
10 | + AS Security; |
|
11 | 11 | use Symfony\Component\Serializer\SerializerInterface; |
12 | 12 | use Symfony\Component\HttpFoundation\RequestStack; |
13 | 13 |
@@ -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 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | namespace ControleOnline\Service; |
4 | 4 | |
5 | 5 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
6 | - AS Security; |
|
6 | + AS Security; |
|
7 | 7 | use Symfony\Component\Serializer\SerializerInterface; |
8 | 8 | use Symfony\Component\HttpFoundation\RequestStack; |
9 | 9 |
@@ -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 | } |
@@ -9,98 +9,98 @@ discard block |
||
9 | 9 | use Exception; |
10 | 10 | use Symfony\Component\HttpFoundation\JsonResponse; |
11 | 11 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
12 | - AS Security; |
|
12 | + AS Security; |
|
13 | 13 | use ControleOnline\Repository\MenuRepository; |
14 | 14 | |
15 | 15 | |
16 | 16 | class GetMenuByPeopleAction |
17 | 17 | { |
18 | - /** |
|
19 | - * Entity Manager |
|
20 | - * |
|
21 | - * @var EntityManagerInterface |
|
22 | - */ |
|
23 | - private $manager = null; |
|
24 | - |
|
25 | - /** |
|
26 | - * Request |
|
27 | - * |
|
28 | - * @var Request |
|
29 | - */ |
|
30 | - private $request = null; |
|
31 | - |
|
32 | - /** |
|
33 | - * Security |
|
34 | - * |
|
35 | - * @var Security |
|
36 | - */ |
|
37 | - private $security = null; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var \ControleOnline\Repository\MenuRepository |
|
41 | - */ |
|
42 | - private $repository = null; |
|
43 | - |
|
44 | - |
|
45 | - public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
46 | - { |
|
18 | + /** |
|
19 | + * Entity Manager |
|
20 | + * |
|
21 | + * @var EntityManagerInterface |
|
22 | + */ |
|
23 | + private $manager = null; |
|
24 | + |
|
25 | + /** |
|
26 | + * Request |
|
27 | + * |
|
28 | + * @var Request |
|
29 | + */ |
|
30 | + private $request = null; |
|
31 | + |
|
32 | + /** |
|
33 | + * Security |
|
34 | + * |
|
35 | + * @var Security |
|
36 | + */ |
|
37 | + private $security = null; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var \ControleOnline\Repository\MenuRepository |
|
41 | + */ |
|
42 | + private $repository = null; |
|
43 | + |
|
44 | + |
|
45 | + public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
46 | + { |
|
47 | 47 | $this->manager = $entityManager; |
48 | 48 | $this->security = $security; |
49 | 49 | $this->repository = $this->manager->getRepository(\ControleOnline\Entity\Menu::class); |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - public function __invoke(Request $request): JsonResponse |
|
53 | - { |
|
52 | + public function __invoke(Request $request): JsonResponse |
|
53 | + { |
|
54 | 54 | try { |
55 | 55 | |
56 | - $menu = []; |
|
56 | + $menu = []; |
|
57 | 57 | |
58 | - $company = $request->query->get('myCompany', null); |
|
58 | + $company = $request->query->get('myCompany', null); |
|
59 | 59 | |
60 | - if ($company === null) |
|
60 | + if ($company === null) |
|
61 | 61 | throw new Exception("Company not found", 404); |
62 | 62 | |
63 | 63 | |
64 | - $myCompany = $this->manager->getRepository(People::class) |
|
64 | + $myCompany = $this->manager->getRepository(People::class) |
|
65 | 65 | ->find($company); |
66 | 66 | |
67 | - if ($myCompany === null) |
|
67 | + if ($myCompany === null) |
|
68 | 68 | throw new Exception("Company not found", 404); |
69 | 69 | |
70 | 70 | |
71 | 71 | |
72 | - $currentUser = $this->security->getToken()->getUser(); |
|
73 | - /** |
|
74 | - * @var People |
|
75 | - */ |
|
76 | - $userPeople = $currentUser->getPeople(); |
|
72 | + $currentUser = $this->security->getToken()->getUser(); |
|
73 | + /** |
|
74 | + * @var People |
|
75 | + */ |
|
76 | + $userPeople = $currentUser->getPeople(); |
|
77 | 77 | |
78 | - $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
78 | + $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
79 | 79 | |
80 | 80 | |
81 | - return new JsonResponse([ |
|
81 | + return new JsonResponse([ |
|
82 | 82 | 'response' => [ |
83 | - 'data' => $menu, |
|
84 | - 'count' => 1, |
|
85 | - 'error' => '', |
|
86 | - 'success' => true, |
|
83 | + 'data' => $menu, |
|
84 | + 'count' => 1, |
|
85 | + 'error' => '', |
|
86 | + 'success' => true, |
|
87 | 87 | ], |
88 | - ]); |
|
88 | + ]); |
|
89 | 89 | } catch (\Exception $e) { |
90 | 90 | |
91 | - return new JsonResponse([ |
|
91 | + return new JsonResponse([ |
|
92 | 92 | 'response' => [ |
93 | - 'data' => [], |
|
94 | - 'count' => 0, |
|
95 | - 'error' => $e->getMessage(), |
|
96 | - 'success' => false, |
|
93 | + 'data' => [], |
|
94 | + 'count' => 0, |
|
95 | + 'error' => $e->getMessage(), |
|
96 | + 'success' => false, |
|
97 | 97 | ], |
98 | - ]); |
|
98 | + ]); |
|
99 | + } |
|
99 | 100 | } |
100 | - } |
|
101 | 101 | |
102 | - private function getMenuByPeople(People $userPeople, People $myCompany) |
|
103 | - { |
|
102 | + private function getMenuByPeople(People $userPeople, People $myCompany) |
|
103 | + { |
|
104 | 104 | |
105 | 105 | $return = []; |
106 | 106 | $connection = $this->manager->getConnection(); |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | |
138 | 138 | foreach ($result as $menu) { |
139 | 139 | |
140 | - $return['modules'][$menu['category_id']]['id'] = $menu['category_id']; |
|
141 | - $return['modules'][$menu['category_id']]['label'] = $menu['category_label']; |
|
142 | - $return['modules'][$menu['category_id']]['color'] = $menu['category_color']; |
|
143 | - $return['modules'][$menu['category_id']]['icon'] = $menu['category_icon']; |
|
144 | - $return['modules'][$menu['category_id']]['menus'][] = [ |
|
140 | + $return['modules'][$menu['category_id']]['id'] = $menu['category_id']; |
|
141 | + $return['modules'][$menu['category_id']]['label'] = $menu['category_label']; |
|
142 | + $return['modules'][$menu['category_id']]['color'] = $menu['category_color']; |
|
143 | + $return['modules'][$menu['category_id']]['icon'] = $menu['category_icon']; |
|
144 | + $return['modules'][$menu['category_id']]['menus'][] = [ |
|
145 | 145 | 'id' => $menu['id'], |
146 | 146 | 'label' => $menu['menu'], |
147 | 147 | 'icon' => $menu['icon'], |
148 | 148 | 'color' => $menu['color'], |
149 | 149 | 'route' => $menu['route'], |
150 | 150 | 'module' => '/modules/' . $menu['module'], |
151 | - ]; |
|
151 | + ]; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | 155 | |
156 | 156 | return $return; |
157 | - } |
|
157 | + } |
|
158 | 158 | } |
@@ -9,97 +9,97 @@ discard block |
||
9 | 9 | use Exception; |
10 | 10 | use Symfony\Component\HttpFoundation\JsonResponse; |
11 | 11 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
12 | - AS Security; |
|
12 | + AS Security; |
|
13 | 13 | |
14 | 14 | |
15 | 15 | |
16 | 16 | class GetActionByPeopleAction |
17 | 17 | { |
18 | - /** |
|
19 | - * Entity Manager |
|
20 | - * |
|
21 | - * @var EntityManagerInterface |
|
22 | - */ |
|
23 | - private $manager = null; |
|
24 | - |
|
25 | - /** |
|
26 | - * Request |
|
27 | - * |
|
28 | - * @var Request |
|
29 | - */ |
|
30 | - private $request = null; |
|
31 | - |
|
32 | - /** |
|
33 | - * Security |
|
34 | - * |
|
35 | - * @var Security |
|
36 | - */ |
|
37 | - private $security = null; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var \ControleOnline\Repository\MenuRepository |
|
41 | - */ |
|
42 | - private $repository = null; |
|
43 | - |
|
44 | - |
|
45 | - public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
46 | - { |
|
18 | + /** |
|
19 | + * Entity Manager |
|
20 | + * |
|
21 | + * @var EntityManagerInterface |
|
22 | + */ |
|
23 | + private $manager = null; |
|
24 | + |
|
25 | + /** |
|
26 | + * Request |
|
27 | + * |
|
28 | + * @var Request |
|
29 | + */ |
|
30 | + private $request = null; |
|
31 | + |
|
32 | + /** |
|
33 | + * Security |
|
34 | + * |
|
35 | + * @var Security |
|
36 | + */ |
|
37 | + private $security = null; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var \ControleOnline\Repository\MenuRepository |
|
41 | + */ |
|
42 | + private $repository = null; |
|
43 | + |
|
44 | + |
|
45 | + public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
46 | + { |
|
47 | 47 | $this->manager = $entityManager; |
48 | 48 | $this->security = $security; |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - public function __invoke(Request $request): JsonResponse |
|
52 | - { |
|
51 | + public function __invoke(Request $request): JsonResponse |
|
52 | + { |
|
53 | 53 | try { |
54 | 54 | |
55 | - $menu = []; |
|
55 | + $menu = []; |
|
56 | 56 | |
57 | - $company = $request->query->get('myCompany', null); |
|
57 | + $company = $request->query->get('myCompany', null); |
|
58 | 58 | |
59 | - if ($company === null) |
|
59 | + if ($company === null) |
|
60 | 60 | throw new Exception("Company not found", 404); |
61 | 61 | |
62 | 62 | |
63 | - $myCompany = $this->manager->getRepository(People::class) |
|
63 | + $myCompany = $this->manager->getRepository(People::class) |
|
64 | 64 | ->find($company); |
65 | 65 | |
66 | - if ($myCompany === null) |
|
66 | + if ($myCompany === null) |
|
67 | 67 | throw new Exception("Company not found", 404); |
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - $currentUser = $this->security->getToken()->getUser(); |
|
72 | - /** |
|
73 | - * @var People |
|
74 | - */ |
|
75 | - $userPeople = $currentUser->getPeople(); |
|
71 | + $currentUser = $this->security->getToken()->getUser(); |
|
72 | + /** |
|
73 | + * @var People |
|
74 | + */ |
|
75 | + $userPeople = $currentUser->getPeople(); |
|
76 | 76 | |
77 | - $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
77 | + $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
78 | 78 | |
79 | 79 | |
80 | - return new JsonResponse([ |
|
80 | + return new JsonResponse([ |
|
81 | 81 | 'response' => [ |
82 | - 'data' => $menu, |
|
83 | - 'count' => 1, |
|
84 | - 'error' => '', |
|
85 | - 'success' => true, |
|
82 | + 'data' => $menu, |
|
83 | + 'count' => 1, |
|
84 | + 'error' => '', |
|
85 | + 'success' => true, |
|
86 | 86 | ], |
87 | - ]); |
|
87 | + ]); |
|
88 | 88 | } catch (\Exception $e) { |
89 | 89 | |
90 | - return new JsonResponse([ |
|
90 | + return new JsonResponse([ |
|
91 | 91 | 'response' => [ |
92 | - 'data' => [], |
|
93 | - 'count' => 0, |
|
94 | - 'error' => $e->getMessage(), |
|
95 | - 'success' => false, |
|
92 | + 'data' => [], |
|
93 | + 'count' => 0, |
|
94 | + 'error' => $e->getMessage(), |
|
95 | + 'success' => false, |
|
96 | 96 | ], |
97 | - ]); |
|
97 | + ]); |
|
98 | + } |
|
98 | 99 | } |
99 | - } |
|
100 | 100 | |
101 | - private function getMenuByPeople(People $userPeople, People $myCompany) |
|
102 | - { |
|
101 | + private function getMenuByPeople(People $userPeople, People $myCompany) |
|
102 | + { |
|
103 | 103 | |
104 | 104 | $return = []; |
105 | 105 | $connection = $this->manager->getConnection(); |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | $result = $statement->fetchAll(); |
135 | 135 | |
136 | 136 | foreach ($result as $action) { |
137 | - $return['routes'][trim($action['route'])]['actions'][$action['id']] = trim($action['action']); |
|
137 | + $return['routes'][trim($action['route'])]['actions'][$action['id']] = trim($action['action']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return $return; |
141 | - } |
|
141 | + } |
|
142 | 142 | } |