1 | <?php |
||
2 | |||
3 | namespace ControleOnline\Controller; |
||
4 | |||
5 | use ControleOnline\Entity\People; |
||
0 ignored issues
–
show
|
|||
6 | use Symfony\Component\HttpFoundation\Request; |
||
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\Request was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
7 | use Doctrine\ORM\EntityManagerInterface; |
||
0 ignored issues
–
show
The type
Doctrine\ORM\EntityManagerInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
8 | use Exception; |
||
9 | use Symfony\Component\HttpFoundation\JsonResponse; |
||
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\JsonResponse was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
10 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface as Security; |
||
0 ignored issues
–
show
The type
Symfony\Component\Securi...e\TokenStorageInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
11 | |||
12 | class GetActionByPeopleAction |
||
13 | { |
||
14 | private $manager = null; |
||
15 | private $security = null; |
||
16 | |||
17 | public function __construct(Security $security, EntityManagerInterface $entityManager) |
||
18 | { |
||
19 | $this->manager = $entityManager; |
||
20 | $this->security = $security; |
||
21 | } |
||
22 | |||
23 | public function __invoke(Request $request): JsonResponse |
||
24 | { |
||
25 | try { |
||
26 | $menu = []; |
||
0 ignored issues
–
show
|
|||
27 | $company = $request->query->get('myCompany', null); |
||
28 | |||
29 | if ($company === null) { |
||
30 | throw new Exception("Company not found", 404); |
||
31 | } |
||
32 | |||
33 | $myCompany = $this->manager->getRepository(People::class)->find($company); |
||
34 | |||
35 | if ($myCompany === null) { |
||
36 | throw new Exception("Company not found", 404); |
||
37 | } |
||
38 | |||
39 | $currentUser = $this->security->getToken()->getUser(); |
||
40 | $userPeople = $currentUser->getPeople(); |
||
41 | |||
42 | $menu = $this->getMenuByPeople($userPeople, $myCompany); |
||
43 | |||
44 | return new JsonResponse([ |
||
45 | 'response' => [ |
||
46 | 'data' => $menu, |
||
47 | 'count' => 1, |
||
48 | 'error' => '', |
||
49 | 'success' => true, |
||
50 | ], |
||
51 | ]); |
||
52 | } catch (\Exception $e) { |
||
53 | return new JsonResponse([ |
||
54 | 'response' => [ |
||
55 | 'data' => [], |
||
56 | 'count' => 0, |
||
57 | 'error' => $e->getMessage(), |
||
58 | 'success' => false, |
||
59 | ], |
||
60 | ]); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | private function getMenuByPeople(People $userPeople, People $myCompany) |
||
65 | { |
||
66 | $return = []; |
||
67 | $connection = $this->manager->getConnection(); |
||
68 | |||
69 | $sql = 'SELECT action.*, routes.route |
||
70 | FROM action |
||
71 | INNER JOIN routes ON routes.id = action.route_id |
||
72 | INNER JOIN action_role ON action_role.action_id = action.id |
||
73 | INNER JOIN role ON role.id = action_role.role_id |
||
74 | INNER JOIN people_role ON people_role.role_id = role.id |
||
75 | WHERE people_role.company_id = :myCompany |
||
76 | AND people_role.people_id = :userPeople |
||
77 | AND routes.route = :route |
||
78 | GROUP BY action.id'; |
||
79 | |||
80 | $params = [ |
||
81 | 'myCompany' => $myCompany->getId(), |
||
82 | 'userPeople' => $userPeople->getId(), |
||
83 | 'route' => $this->route, |
||
0 ignored issues
–
show
|
|||
84 | ]; |
||
85 | |||
86 | $result = $connection->executeQuery($sql, $params)->fetchAllAssociative(); |
||
87 | |||
88 | foreach ($result as $action) { |
||
89 | $return['routes'][trim($action['route'])]['actions'][$action['id']] = trim($action['action']); |
||
90 | } |
||
91 | |||
92 | return $return; |
||
93 | } |
||
94 | } |
||
95 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths