Passed
Push — master ( 26d7e0...0f4508 )
by Luiz Kim
02:38
created
src/Controller/GetMenuByPeopleAction.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -14,92 +14,92 @@  discard block
 block discarded – undo
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();
@@ -136,22 +136,22 @@  discard block
 block discarded – undo
136 136
 
137 137
     foreach ($result as $menu) {
138 138
 
139
-      $return['modules'][$menu['category_id']]['id'] = $menu['category_id'];
140
-      $return['modules'][$menu['category_id']]['label'] = $menu['category_label'];
141
-      $return['modules'][$menu['category_id']]['color'] = $menu['category_color'];
142
-      $return['modules'][$menu['category_id']]['icon'] = $menu['category_icon'];
143
-      $return['modules'][$menu['category_id']]['menus'][] = [
139
+        $return['modules'][$menu['category_id']]['id'] = $menu['category_id'];
140
+        $return['modules'][$menu['category_id']]['label'] = $menu['category_label'];
141
+        $return['modules'][$menu['category_id']]['color'] = $menu['category_color'];
142
+        $return['modules'][$menu['category_id']]['icon'] = $menu['category_icon'];
143
+        $return['modules'][$menu['category_id']]['menus'][] = [
144 144
         'id' => $menu['id'],
145 145
         'label' =>  $menu['menu'],
146 146
         'icon' =>  $menu['icon'],
147 147
         'color' =>  $menu['color'],
148 148
         'route' =>  $menu['route'],
149 149
         'module' =>  '/modules/' . $menu['module'],
150
-      ];
150
+        ];
151 151
     }
152 152
 
153 153
 
154 154
 
155 155
     return $return;
156
-  }
156
+    }
157 157
 }
Please login to merge, or discard this patch.