Passed
Push — master ( fd4671...566008 )
by Luiz Kim
02:46
created
src/Controller/GetMenuByPeopleAction.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -15,92 +15,92 @@  discard block
 block discarded – undo
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(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();
@@ -133,22 +133,22 @@  discard block
 block discarded – undo
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
         'module' =>  '/modules/' . $menu['module'],
147
-      ];
147
+        ];
148 148
     }
149 149
 
150 150
 
151 151
 
152 152
     return $return;
153
-  }
153
+    }
154 154
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
    *
28 28
    * @var Request
29 29
    */
30
-  private $request  = null;
30
+  private $request = null;
31 31
 
32 32
   /**
33 33
    * Security
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
   {
54 54
     try {
55 55
 
56
-      $menu  = [];
56
+      $menu = [];
57 57
 
58 58
       $company = $request->query->get('myCompany', null);
59 59
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
        */
76 76
       $userPeople = $currentUser->getPeople();
77 77
 
78
-      $menu =  $this->getMenuByPeople($userPeople, $myCompany);
78
+      $menu = $this->getMenuByPeople($userPeople, $myCompany);
79 79
 
80 80
 
81 81
       return new JsonResponse([
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
     // build query
109 109
 
110
-    $sql  = 'SELECT menu.*,
110
+    $sql = 'SELECT menu.*,
111 111
             category.name AS category_label,
112 112
             category.color AS category_color,
113 113
             routes.route AS route,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
              INNER JOIN people_role ON people_role.role_id = menu_role.role_id    
121 121
              INNER JOIN routes ON routes.id = menu.route_id ';
122 122
     //$sql  .= 'WHERE people_role.company_id=:myCompany AND people_role.people_id=:userPeople ';
123
-    $sql  .= 'GROUP BY menu.id';
123
+    $sql .= 'GROUP BY menu.id';
124 124
 
125 125
 
126 126
     $params = [];
Please login to merge, or discard this patch.