@@ -14,92 +14,92 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class GetMenuByPeopleAction |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Entity Manager |
|
| 19 | - * |
|
| 20 | - * @var EntityManagerInterface |
|
| 21 | - */ |
|
| 22 | - private $manager = null; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Request |
|
| 26 | - * |
|
| 27 | - * @var Request |
|
| 28 | - */ |
|
| 29 | - private $request = null; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Security |
|
| 33 | - * |
|
| 34 | - * @var Security |
|
| 35 | - */ |
|
| 36 | - private $security = null; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var \ControleOnline\Repository\MenuRepository |
|
| 40 | - */ |
|
| 41 | - private $repository = null; |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
| 45 | - { |
|
| 17 | + /** |
|
| 18 | + * Entity Manager |
|
| 19 | + * |
|
| 20 | + * @var EntityManagerInterface |
|
| 21 | + */ |
|
| 22 | + private $manager = null; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Request |
|
| 26 | + * |
|
| 27 | + * @var Request |
|
| 28 | + */ |
|
| 29 | + private $request = null; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Security |
|
| 33 | + * |
|
| 34 | + * @var Security |
|
| 35 | + */ |
|
| 36 | + private $security = null; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var \ControleOnline\Repository\MenuRepository |
|
| 40 | + */ |
|
| 41 | + private $repository = null; |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
| 45 | + { |
|
| 46 | 46 | $this->manager = $entityManager; |
| 47 | 47 | $this->security = $security; |
| 48 | 48 | $this->repository = $this->manager->getRepository(\ControleOnline\Entity\Menu::class); |
| 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->getUser(); |
|
| 72 | - /** |
|
| 73 | - * @var People |
|
| 74 | - */ |
|
| 75 | - $userPeople = $currentUser->getPeople(); |
|
| 71 | + $currentUser = $this->security->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(); |
@@ -133,21 +133,21 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | foreach ($result as $menu) { |
| 135 | 135 | |
| 136 | - $return['modules'][$menu['category_id']]['id'] = $menu['category_id']; |
|
| 137 | - $return['modules'][$menu['category_id']]['label'] = $menu['category_label']; |
|
| 138 | - $return['modules'][$menu['category_id']]['color'] = $menu['category_color']; |
|
| 139 | - $return['modules'][$menu['category_id']]['icon'] = $menu['category_icon']; |
|
| 140 | - $return['modules'][$menu['category_id']]['menus'][] = [ |
|
| 136 | + $return['modules'][$menu['category_id']]['id'] = $menu['category_id']; |
|
| 137 | + $return['modules'][$menu['category_id']]['label'] = $menu['category_label']; |
|
| 138 | + $return['modules'][$menu['category_id']]['color'] = $menu['category_color']; |
|
| 139 | + $return['modules'][$menu['category_id']]['icon'] = $menu['category_icon']; |
|
| 140 | + $return['modules'][$menu['category_id']]['menus'][] = [ |
|
| 141 | 141 | 'id' => $menu['id'], |
| 142 | 142 | 'label' => $menu['menu'], |
| 143 | 143 | 'icon' => $menu['icon'], |
| 144 | 144 | 'color' => $menu['color'], |
| 145 | 145 | 'route' => $menu['route'], |
| 146 | - ]; |
|
| 146 | + ]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | |
| 151 | 151 | return $return; |
| 152 | - } |
|
| 152 | + } |
|
| 153 | 153 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @var Request |
| 28 | 28 | */ |
| 29 | - private $request = null; |
|
| 29 | + private $request = null; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Security |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | try { |
| 54 | 54 | |
| 55 | - $menu = []; |
|
| 55 | + $menu = []; |
|
| 56 | 56 | |
| 57 | 57 | $company = $request->query->get('myCompany', null); |
| 58 | 58 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | $userPeople = $currentUser->getPeople(); |
| 76 | 76 | |
| 77 | - $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
| 77 | + $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | return new JsonResponse([ |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // build query |
| 108 | 108 | |
| 109 | - $sql = 'SELECT menu.*, |
|
| 109 | + $sql = 'SELECT menu.*, |
|
| 110 | 110 | category.name AS category_label, |
| 111 | 111 | category.color AS category_color, |
| 112 | 112 | routes.route AS route, |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $params = []; |
| 124 | 124 | |
| 125 | - $params['myCompany'] = $myCompany->getId(); |
|
| 126 | - $params['userPeople'] = $userPeople->getId(); |
|
| 125 | + $params['myCompany'] = $myCompany->getId(); |
|
| 126 | + $params['userPeople'] = $userPeople->getId(); |
|
| 127 | 127 | // execute query |
| 128 | 128 | |
| 129 | 129 | $statement = $connection->prepare($sql); |
@@ -56,15 +56,17 @@ |
||
| 56 | 56 | |
| 57 | 57 | $company = $request->query->get('myCompany', null); |
| 58 | 58 | |
| 59 | - if ($company === null) |
|
| 60 | - throw new Exception("Company not found", 404); |
|
| 59 | + if ($company === null) { |
|
| 60 | + throw new Exception("Company not found", 404); |
|
| 61 | + } |
|
| 61 | 62 | |
| 62 | 63 | |
| 63 | 64 | $myCompany = $this->manager->getRepository(People::class) |
| 64 | 65 | ->find($company); |
| 65 | 66 | |
| 66 | - if ($myCompany === null) |
|
| 67 | - throw new Exception("Company not found", 404); |
|
| 67 | + if ($myCompany === null) { |
|
| 68 | + throw new Exception("Company not found", 404); |
|
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | |
| 70 | 72 | |
@@ -14,91 +14,91 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class GetActionByPeopleAction |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Entity Manager |
|
| 19 | - * |
|
| 20 | - * @var EntityManagerInterface |
|
| 21 | - */ |
|
| 22 | - private $manager = null; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Request |
|
| 26 | - * |
|
| 27 | - * @var Request |
|
| 28 | - */ |
|
| 29 | - private $request = null; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Security |
|
| 33 | - * |
|
| 34 | - * @var Security |
|
| 35 | - */ |
|
| 36 | - private $security = null; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var \ControleOnline\Repository\MenuRepository |
|
| 40 | - */ |
|
| 41 | - private $repository = null; |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
| 45 | - { |
|
| 17 | + /** |
|
| 18 | + * Entity Manager |
|
| 19 | + * |
|
| 20 | + * @var EntityManagerInterface |
|
| 21 | + */ |
|
| 22 | + private $manager = null; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Request |
|
| 26 | + * |
|
| 27 | + * @var Request |
|
| 28 | + */ |
|
| 29 | + private $request = null; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Security |
|
| 33 | + * |
|
| 34 | + * @var Security |
|
| 35 | + */ |
|
| 36 | + private $security = null; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var \ControleOnline\Repository\MenuRepository |
|
| 40 | + */ |
|
| 41 | + private $repository = null; |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + public function __construct(Security $security, EntityManagerInterface $entityManager) |
|
| 45 | + { |
|
| 46 | 46 | $this->manager = $entityManager; |
| 47 | 47 | $this->security = $security; |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function __invoke(Request $request): JsonResponse |
|
| 51 | - { |
|
| 50 | + public function __invoke(Request $request): JsonResponse |
|
| 51 | + { |
|
| 52 | 52 | try { |
| 53 | 53 | |
| 54 | - $menu = []; |
|
| 54 | + $menu = []; |
|
| 55 | 55 | |
| 56 | - $company = $request->query->get('myCompany', null); |
|
| 56 | + $company = $request->query->get('myCompany', null); |
|
| 57 | 57 | |
| 58 | - if ($company === null) |
|
| 58 | + if ($company === null) |
|
| 59 | 59 | throw new Exception("Company not found", 404); |
| 60 | 60 | |
| 61 | 61 | |
| 62 | - $myCompany = $this->manager->getRepository(People::class) |
|
| 62 | + $myCompany = $this->manager->getRepository(People::class) |
|
| 63 | 63 | ->find($company); |
| 64 | 64 | |
| 65 | - if ($myCompany === null) |
|
| 65 | + if ($myCompany === null) |
|
| 66 | 66 | throw new Exception("Company not found", 404); |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - $currentUser = $this->security->getUser(); |
|
| 71 | - /** |
|
| 72 | - * @var People |
|
| 73 | - */ |
|
| 74 | - $userPeople = $currentUser->getPeople(); |
|
| 70 | + $currentUser = $this->security->getUser(); |
|
| 71 | + /** |
|
| 72 | + * @var People |
|
| 73 | + */ |
|
| 74 | + $userPeople = $currentUser->getPeople(); |
|
| 75 | 75 | |
| 76 | - $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
| 76 | + $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | - return new JsonResponse([ |
|
| 79 | + return new JsonResponse([ |
|
| 80 | 80 | 'response' => [ |
| 81 | - 'data' => $menu, |
|
| 82 | - 'count' => 1, |
|
| 83 | - 'error' => '', |
|
| 84 | - 'success' => true, |
|
| 81 | + 'data' => $menu, |
|
| 82 | + 'count' => 1, |
|
| 83 | + 'error' => '', |
|
| 84 | + 'success' => true, |
|
| 85 | 85 | ], |
| 86 | - ]); |
|
| 86 | + ]); |
|
| 87 | 87 | } catch (\Exception $e) { |
| 88 | 88 | |
| 89 | - return new JsonResponse([ |
|
| 89 | + return new JsonResponse([ |
|
| 90 | 90 | 'response' => [ |
| 91 | - 'data' => [], |
|
| 92 | - 'count' => 0, |
|
| 93 | - 'error' => $e->getMessage(), |
|
| 94 | - 'success' => false, |
|
| 91 | + 'data' => [], |
|
| 92 | + 'count' => 0, |
|
| 93 | + 'error' => $e->getMessage(), |
|
| 94 | + 'success' => false, |
|
| 95 | 95 | ], |
| 96 | - ]); |
|
| 96 | + ]); |
|
| 97 | + } |
|
| 97 | 98 | } |
| 98 | - } |
|
| 99 | 99 | |
| 100 | - private function getMenuByPeople(People $userPeople, People $myCompany) |
|
| 101 | - { |
|
| 100 | + private function getMenuByPeople(People $userPeople, People $myCompany) |
|
| 101 | + { |
|
| 102 | 102 | |
| 103 | 103 | $return = []; |
| 104 | 104 | $connection = $this->manager->getConnection(); |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | $result = $statement->fetchAll(); |
| 134 | 134 | |
| 135 | 135 | foreach ($result as $action) { |
| 136 | - $return['routes'][trim($action['route'])]['actions'][$action['id']] = trim($action['action']); |
|
| 136 | + $return['routes'][trim($action['route'])]['actions'][$action['id']] = trim($action['action']); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return $return; |
| 140 | - } |
|
| 140 | + } |
|
| 141 | 141 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @var Request |
| 28 | 28 | */ |
| 29 | - private $request = null; |
|
| 29 | + private $request = null; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Security |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | try { |
| 53 | 53 | |
| 54 | - $menu = []; |
|
| 54 | + $menu = []; |
|
| 55 | 55 | |
| 56 | 56 | $company = $request->query->get('myCompany', null); |
| 57 | 57 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | $userPeople = $currentUser->getPeople(); |
| 75 | 75 | |
| 76 | - $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
| 76 | + $menu = $this->getMenuByPeople($userPeople, $myCompany); |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | return new JsonResponse([ |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // build query |
| 107 | 107 | |
| 108 | - $sql = 'SELECT action.*,routes.route |
|
| 108 | + $sql = 'SELECT action.*,routes.route |
|
| 109 | 109 | |
| 110 | 110 | FROM action |
| 111 | 111 | INNER JOIN routes ON routes.id = action.route_id |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $params = []; |
| 124 | 124 | |
| 125 | - $params['myCompany'] = $myCompany->getId(); |
|
| 126 | - $params['userPeople'] = $userPeople->getId(); |
|
| 127 | - $params['route'] = $this->route; |
|
| 125 | + $params['myCompany'] = $myCompany->getId(); |
|
| 126 | + $params['userPeople'] = $userPeople->getId(); |
|
| 127 | + $params['route'] = $this->route; |
|
| 128 | 128 | // execute query |
| 129 | 129 | |
| 130 | 130 | $statement = $connection->prepare($sql); |
@@ -55,15 +55,17 @@ |
||
| 55 | 55 | |
| 56 | 56 | $company = $request->query->get('myCompany', null); |
| 57 | 57 | |
| 58 | - if ($company === null) |
|
| 59 | - throw new Exception("Company not found", 404); |
|
| 58 | + if ($company === null) { |
|
| 59 | + throw new Exception("Company not found", 404); |
|
| 60 | + } |
|
| 60 | 61 | |
| 61 | 62 | |
| 62 | 63 | $myCompany = $this->manager->getRepository(People::class) |
| 63 | 64 | ->find($company); |
| 64 | 65 | |
| 65 | - if ($myCompany === null) |
|
| 66 | - throw new Exception("Company not found", 404); |
|
| 66 | + if ($myCompany === null) { |
|
| 67 | + throw new Exception("Company not found", 404); |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | |
| 69 | 71 | |