@@ -125,15 +125,16 @@ |
||
125 | 125 | |
126 | 126 | private function log() |
127 | 127 | { |
128 | - if (get_class($this->entity) == 'ControleOnline\Entity\Webapi\Usuario') |
|
129 | - $this->user = $this->entity; |
|
130 | - else |
|
131 | - $this->log[] = |
|
128 | + if (get_class($this->entity) == 'ControleOnline\Entity\Webapi\Usuario') { |
|
129 | + $this->user = $this->entity; |
|
130 | + } else { |
|
131 | + $this->log[] = |
|
132 | 132 | [ |
133 | 133 | 'action' => $this->action, |
134 | 134 | 'class' => str_replace('Proxies\\__CG__\\', '', get_class($this->entity)), |
135 | 135 | 'object' => $this->getObject($this->entity) |
136 | 136 | ]; |
137 | + } |
|
137 | 138 | } |
138 | 139 | |
139 | 140 | private function getObject($entity) |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $css = ':root{' . PHP_EOL; |
35 | 35 | foreach ($theme->getColors(true) as $index => $color) { |
36 | 36 | $css .= ' --q-' . $index . ': ' . $color . ';' . PHP_EOL; |
37 | - $css .= ' --' . $index . ': ' . $color . ';' . PHP_EOL; |
|
37 | + $css .= ' --' . $index . ': ' . $color . ';' . PHP_EOL; |
|
38 | 38 | } |
39 | 39 | $css .= '}'; |
40 | 40 | return new Response($css, Response::HTTP_OK, [ |
@@ -89,11 +89,13 @@ |
||
89 | 89 | private function getMembers($class, $groups, mixed $arguments = [], int $limit = 0, int $page = 1, array $orderby = []) |
90 | 90 | { |
91 | 91 | |
92 | - if ($limit < 1) |
|
93 | - $limit = $this->request->get('itemsPerPage') ?: 50; |
|
92 | + if ($limit < 1) { |
|
93 | + $limit = $this->request->get('itemsPerPage') ?: 50; |
|
94 | + } |
|
94 | 95 | |
95 | - if ($page == 1) |
|
96 | - $offset = (($page = $this->request->get('page') ?: 1) - 1) * $limit; |
|
96 | + if ($page == 1) { |
|
97 | + $offset = (($page = $this->request->get('page') ?: 1) - 1) * $limit; |
|
98 | + } |
|
97 | 99 | |
98 | 100 | $data = $this->manager->getRepository($class)->findBy($arguments, $orderby, $limit, $offset); |
99 | 101 |
@@ -31,23 +31,23 @@ discard block |
||
31 | 31 | return $e; |
32 | 32 | } |
33 | 33 | |
34 | - public function collectionData($data, $class, $groups, mixed $arguments = []) |
|
34 | + public function collectionData($data, $class, $groups, mixed $arguments = []) |
|
35 | 35 | { |
36 | 36 | $response = $this->getBasicResponse($class); |
37 | 37 | |
38 | - $response['hydra:member'] = $this->data($data, $groups); |
|
39 | - $response['hydra:search'] = $this->getSearch($class); |
|
40 | - $response['hydra:totalItems'] = $this->getCount($class, $arguments); |
|
38 | + $response['hydra:member'] = $this->data($data, $groups); |
|
39 | + $response['hydra:search'] = $this->getSearch($class); |
|
40 | + $response['hydra:totalItems'] = $this->getCount($class, $arguments); |
|
41 | 41 | |
42 | 42 | return $response; |
43 | 43 | } |
44 | - public function collection($class, $groups, mixed $arguments = [], int $limit = 0, int $page = 1, array $orderby = []) |
|
44 | + public function collection($class, $groups, mixed $arguments = [], int $limit = 0, int $page = 1, array $orderby = []) |
|
45 | 45 | { |
46 | 46 | $response = $this->getBasicResponse($class); |
47 | 47 | |
48 | - $response['hydra:member'] = $this->getMembers($class, $groups, $arguments, $limit, $page, $orderby); |
|
49 | - $response['hydra:search'] = $this->getSearch($class); |
|
50 | - $response['hydra:totalItems'] = $this->getCount($class, $arguments); |
|
48 | + $response['hydra:member'] = $this->getMembers($class, $groups, $arguments, $limit, $page, $orderby); |
|
49 | + $response['hydra:search'] = $this->getSearch($class); |
|
50 | + $response['hydra:totalItems'] = $this->getCount($class, $arguments); |
|
51 | 51 | |
52 | 52 | return $response; |
53 | 53 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | //$response = $this->getBasicResponse($class); |
58 | 58 | //$response['hydra:search'] = $this->getSearch($class); |
59 | 59 | |
60 | - $response['hydra:member'] = $result; |
|
61 | - $response['hydra:totalItems'] = count($response['hydra:member']); |
|
60 | + $response['hydra:member'] = $result; |
|
61 | + $response['hydra:totalItems'] = count($response['hydra:member']); |
|
62 | 62 | |
63 | 63 | return $response; |
64 | 64 | } |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $className = substr($class, strrpos($class, '\\') + 1); |
82 | 82 | |
83 | 83 | $response['@id'] = '/' . strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $className)) . 's'; |
84 | - $response['@context'] = "/contexts/" . $className; |
|
85 | - $response['@type'] = "hydra:Collection"; |
|
84 | + $response['@context'] = "/contexts/" . $className; |
|
85 | + $response['@type'] = "hydra:Collection"; |
|
86 | 86 | |
87 | 87 | $response['hydra:view'] = [ |
88 | 88 | '@id' => $this->uri, |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | if ($page == 1) |
101 | 101 | $offset = (($page = $this->request->get('page') ?: 1) - 1) * $limit; |
102 | 102 | |
103 | - $data = $this->manager->getRepository($class)->findBy($arguments, $orderby, $limit, $offset); |
|
103 | + $data = $this->manager->getRepository($class)->findBy($arguments, $orderby, $limit, $offset); |
|
104 | 104 | |
105 | 105 | return $this->serialize($data, ['groups' => $groups]); |
106 | 106 | } |
@@ -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 |
@@ -22,65 +22,65 @@ |
||
22 | 22 | |
23 | 23 | public function findOneByCityStateCountryOfPeople(string $city, string $state, string $country, People $people): ?Address |
24 | 24 | { |
25 | - $result = $this->createQueryBuilder('a') |
|
26 | - ->innerJoin ('a.street' , 's') |
|
27 | - ->innerJoin ('s.district', 'd') |
|
28 | - ->innerJoin ('d.city' , 'c') |
|
29 | - ->innerJoin ('c.state' , 'e') |
|
30 | - ->innerJoin ('e.country' , 'u') |
|
25 | + $result = $this->createQueryBuilder('a') |
|
26 | + ->innerJoin ('a.street' , 's') |
|
27 | + ->innerJoin ('s.district', 'd') |
|
28 | + ->innerJoin ('d.city' , 'c') |
|
29 | + ->innerJoin ('c.state' , 'e') |
|
30 | + ->innerJoin ('e.country' , 'u') |
|
31 | 31 | |
32 | - ->andWhere ('c.city = :city' ) |
|
33 | - ->andWhere ('e.uf = :state' ) |
|
34 | - ->andWhere ('u.countryname = :country') |
|
35 | - ->andWhere ('a.people = :people' ) |
|
32 | + ->andWhere ('c.city = :city' ) |
|
33 | + ->andWhere ('e.uf = :state' ) |
|
34 | + ->andWhere ('u.countryname = :country') |
|
35 | + ->andWhere ('a.people = :people' ) |
|
36 | 36 | |
37 | - ->setParameter ('city' , $city ) |
|
38 | - ->setParameter ('state' , $state ) |
|
39 | - ->setParameter ('country', $country) |
|
40 | - ->setParameter ('people' , $people) |
|
37 | + ->setParameter ('city' , $city ) |
|
38 | + ->setParameter ('state' , $state ) |
|
39 | + ->setParameter ('country', $country) |
|
40 | + ->setParameter ('people' , $people) |
|
41 | 41 | |
42 | - ->getQuery() |
|
43 | - ->getResult() |
|
44 | - ; |
|
42 | + ->getQuery() |
|
43 | + ->getResult() |
|
44 | + ; |
|
45 | 45 | |
46 | - if (empty($result)) |
|
46 | + if (empty($result)) |
|
47 | 47 | return null; |
48 | 48 | |
49 | - return $result[0]; |
|
49 | + return $result[0]; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function findPeopleAddressBy(People $people, array $criteria): ?Address |
53 | 53 | { |
54 | - $result = $this->createQueryBuilder('a') |
|
55 | - ->innerJoin ('a.street' , 's') |
|
56 | - ->innerJoin ('s.district', 'd') |
|
57 | - ->innerJoin ('d.city' , 'c') |
|
58 | - ->innerJoin ('c.state' , 'e') |
|
59 | - ->innerJoin ('e.country' , 'u') |
|
54 | + $result = $this->createQueryBuilder('a') |
|
55 | + ->innerJoin ('a.street' , 's') |
|
56 | + ->innerJoin ('s.district', 'd') |
|
57 | + ->innerJoin ('d.city' , 'c') |
|
58 | + ->innerJoin ('c.state' , 'e') |
|
59 | + ->innerJoin ('e.country' , 'u') |
|
60 | 60 | |
61 | - ->andWhere ('a.people = :people' ) |
|
62 | - ->andWhere ('u.countryname = :country' ) |
|
63 | - ->andWhere ('(e.uf = :state OR e.state = :state)') |
|
64 | - ->andWhere ('c.city = :city' ) |
|
65 | - ->andWhere ('d.district = :district') |
|
66 | - ->andWhere ('s.street = :street' ) |
|
67 | - ->andWhere ('a.number = :number' ) |
|
61 | + ->andWhere ('a.people = :people' ) |
|
62 | + ->andWhere ('u.countryname = :country' ) |
|
63 | + ->andWhere ('(e.uf = :state OR e.state = :state)') |
|
64 | + ->andWhere ('c.city = :city' ) |
|
65 | + ->andWhere ('d.district = :district') |
|
66 | + ->andWhere ('s.street = :street' ) |
|
67 | + ->andWhere ('a.number = :number' ) |
|
68 | 68 | |
69 | - ->setParameter ('people' , $people) |
|
70 | - ->setParameter ('country' , $criteria['country'] ) |
|
71 | - ->setParameter ('state' , $criteria['state'] ) |
|
72 | - ->setParameter ('city' , $criteria['city'] ) |
|
73 | - ->setParameter ('district', $criteria['district']) |
|
74 | - ->setParameter ('street' , $criteria['street'] ) |
|
75 | - ->setParameter ('number' , $criteria['number'] ) |
|
69 | + ->setParameter ('people' , $people) |
|
70 | + ->setParameter ('country' , $criteria['country'] ) |
|
71 | + ->setParameter ('state' , $criteria['state'] ) |
|
72 | + ->setParameter ('city' , $criteria['city'] ) |
|
73 | + ->setParameter ('district', $criteria['district']) |
|
74 | + ->setParameter ('street' , $criteria['street'] ) |
|
75 | + ->setParameter ('number' , $criteria['number'] ) |
|
76 | 76 | |
77 | - ->getQuery() |
|
78 | - ->getResult() |
|
79 | - ; |
|
77 | + ->getQuery() |
|
78 | + ->getResult() |
|
79 | + ; |
|
80 | 80 | |
81 | - if (empty($result)) |
|
81 | + if (empty($result)) |
|
82 | 82 | return null; |
83 | 83 | |
84 | - return $result[0]; |
|
84 | + return $result[0]; |
|
85 | 85 | } |
86 | 86 | } |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | public function findOneByCityStateCountryOfPeople(string $city, string $state, string $country, People $people): ?Address |
24 | 24 | { |
25 | 25 | $result = $this->createQueryBuilder('a') |
26 | - ->innerJoin ('a.street' , 's') |
|
27 | - ->innerJoin ('s.district', 'd') |
|
28 | - ->innerJoin ('d.city' , 'c') |
|
29 | - ->innerJoin ('c.state' , 'e') |
|
30 | - ->innerJoin ('e.country' , 'u') |
|
26 | + ->innerJoin('a.street', 's') |
|
27 | + ->innerJoin('s.district', 'd') |
|
28 | + ->innerJoin('d.city', 'c') |
|
29 | + ->innerJoin('c.state', 'e') |
|
30 | + ->innerJoin('e.country', 'u') |
|
31 | 31 | |
32 | - ->andWhere ('c.city = :city' ) |
|
33 | - ->andWhere ('e.uf = :state' ) |
|
34 | - ->andWhere ('u.countryname = :country') |
|
35 | - ->andWhere ('a.people = :people' ) |
|
32 | + ->andWhere('c.city = :city') |
|
33 | + ->andWhere('e.uf = :state') |
|
34 | + ->andWhere('u.countryname = :country') |
|
35 | + ->andWhere('a.people = :people') |
|
36 | 36 | |
37 | - ->setParameter ('city' , $city ) |
|
38 | - ->setParameter ('state' , $state ) |
|
39 | - ->setParameter ('country', $country) |
|
40 | - ->setParameter ('people' , $people) |
|
37 | + ->setParameter('city', $city) |
|
38 | + ->setParameter('state', $state) |
|
39 | + ->setParameter('country', $country) |
|
40 | + ->setParameter('people', $people) |
|
41 | 41 | |
42 | 42 | ->getQuery() |
43 | 43 | ->getResult() |
@@ -52,27 +52,27 @@ discard block |
||
52 | 52 | public function findPeopleAddressBy(People $people, array $criteria): ?Address |
53 | 53 | { |
54 | 54 | $result = $this->createQueryBuilder('a') |
55 | - ->innerJoin ('a.street' , 's') |
|
56 | - ->innerJoin ('s.district', 'd') |
|
57 | - ->innerJoin ('d.city' , 'c') |
|
58 | - ->innerJoin ('c.state' , 'e') |
|
59 | - ->innerJoin ('e.country' , 'u') |
|
55 | + ->innerJoin('a.street', 's') |
|
56 | + ->innerJoin('s.district', 'd') |
|
57 | + ->innerJoin('d.city', 'c') |
|
58 | + ->innerJoin('c.state', 'e') |
|
59 | + ->innerJoin('e.country', 'u') |
|
60 | 60 | |
61 | - ->andWhere ('a.people = :people' ) |
|
62 | - ->andWhere ('u.countryname = :country' ) |
|
63 | - ->andWhere ('(e.uf = :state OR e.state = :state)') |
|
64 | - ->andWhere ('c.city = :city' ) |
|
65 | - ->andWhere ('d.district = :district') |
|
66 | - ->andWhere ('s.street = :street' ) |
|
67 | - ->andWhere ('a.number = :number' ) |
|
61 | + ->andWhere('a.people = :people') |
|
62 | + ->andWhere('u.countryname = :country') |
|
63 | + ->andWhere('(e.uf = :state OR e.state = :state)') |
|
64 | + ->andWhere('c.city = :city') |
|
65 | + ->andWhere('d.district = :district') |
|
66 | + ->andWhere('s.street = :street') |
|
67 | + ->andWhere('a.number = :number') |
|
68 | 68 | |
69 | - ->setParameter ('people' , $people) |
|
70 | - ->setParameter ('country' , $criteria['country'] ) |
|
71 | - ->setParameter ('state' , $criteria['state'] ) |
|
72 | - ->setParameter ('city' , $criteria['city'] ) |
|
73 | - ->setParameter ('district', $criteria['district']) |
|
74 | - ->setParameter ('street' , $criteria['street'] ) |
|
75 | - ->setParameter ('number' , $criteria['number'] ) |
|
69 | + ->setParameter('people', $people) |
|
70 | + ->setParameter('country', $criteria['country']) |
|
71 | + ->setParameter('state', $criteria['state']) |
|
72 | + ->setParameter('city', $criteria['city']) |
|
73 | + ->setParameter('district', $criteria['district']) |
|
74 | + ->setParameter('street', $criteria['street']) |
|
75 | + ->setParameter('number', $criteria['number']) |
|
76 | 76 | |
77 | 77 | ->getQuery() |
78 | 78 | ->getResult() |
@@ -43,8 +43,9 @@ discard block |
||
43 | 43 | ->getResult() |
44 | 44 | ; |
45 | 45 | |
46 | - if (empty($result)) |
|
47 | - return null; |
|
46 | + if (empty($result)) { |
|
47 | + return null; |
|
48 | + } |
|
48 | 49 | |
49 | 50 | return $result[0]; |
50 | 51 | } |
@@ -78,8 +79,9 @@ discard block |
||
78 | 79 | ->getResult() |
79 | 80 | ; |
80 | 81 | |
81 | - if (empty($result)) |
|
82 | - return null; |
|
82 | + if (empty($result)) { |
|
83 | + return null; |
|
84 | + } |
|
83 | 85 | |
84 | 86 | return $result[0]; |
85 | 87 | } |
@@ -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 |
@@ -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 | } |
@@ -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); |
@@ -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 |
@@ -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 | } |
@@ -64,8 +64,9 @@ discard block |
||
64 | 64 | ->getQuery() |
65 | 65 | ->getResult(); |
66 | 66 | |
67 | - if (empty($result)) |
|
68 | - return null; |
|
67 | + if (empty($result)) { |
|
68 | + return null; |
|
69 | + } |
|
69 | 70 | |
70 | 71 | $configs = []; |
71 | 72 | |
@@ -88,8 +89,9 @@ discard block |
||
88 | 89 | ]); |
89 | 90 | |
90 | 91 | |
91 | - if (empty($config) || $config->getConfigValue() != 'itau') |
|
92 | - return null; |
|
92 | + if (empty($config) || $config->getConfigValue() != 'itau') { |
|
93 | + return null; |
|
94 | + } |
|
93 | 95 | |
94 | 96 | $result = $this->createQueryBuilder('a') |
95 | 97 | ->andWhere('a.people = :people') |
@@ -99,8 +101,9 @@ discard block |
||
99 | 101 | ->getQuery() |
100 | 102 | ->getResult(); |
101 | 103 | |
102 | - if (empty($result)) |
|
103 | - return null; |
|
104 | + if (empty($result)) { |
|
105 | + return null; |
|
106 | + } |
|
104 | 107 | |
105 | 108 | $configs = []; |
106 | 109 | |
@@ -125,8 +128,9 @@ discard block |
||
125 | 128 | ->getQuery() |
126 | 129 | ->getResult(); |
127 | 130 | |
128 | - if (empty($result)) |
|
129 | - return null; |
|
131 | + if (empty($result)) { |
|
132 | + return null; |
|
133 | + } |
|
130 | 134 | |
131 | 135 | $configs = []; |
132 | 136 |
@@ -15,57 +15,57 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class ConfigRepository extends ServiceEntityRepository |
17 | 17 | { |
18 | - public function __construct(ManagerRegistry $registry) |
|
19 | - { |
|
18 | + public function __construct(ManagerRegistry $registry) |
|
19 | + { |
|
20 | 20 | parent::__construct($registry, Config::class); |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - public function updatePeopleConfigKey(People $people, string $key, string $value): void |
|
24 | - { |
|
23 | + public function updatePeopleConfigKey(People $people, string $key, string $value): void |
|
24 | + { |
|
25 | 25 | try { |
26 | - $params = []; |
|
26 | + $params = []; |
|
27 | 27 | |
28 | - $this->getEntityManager()->getConnection() |
|
28 | + $this->getEntityManager()->getConnection() |
|
29 | 29 | ->executeQuery('START TRANSACTION', $params); |
30 | 30 | |
31 | - $rawSQL = <<<SQL |
|
31 | + $rawSQL = <<<SQL |
|
32 | 32 | UPDATE config |
33 | 33 | SET configValue = :value |
34 | 34 | WHERE people_id = :id AND configKey = :key |
35 | 35 | SQL; |
36 | 36 | |
37 | - $params = [ |
|
37 | + $params = [ |
|
38 | 38 | 'id' => $people->getId(), |
39 | 39 | 'key' => $key, |
40 | 40 | 'value' => $value, |
41 | - ]; |
|
41 | + ]; |
|
42 | 42 | |
43 | - $this->getEntityManager()->getConnection() |
|
43 | + $this->getEntityManager()->getConnection() |
|
44 | 44 | ->executeQuery($rawSQL, $params); |
45 | 45 | |
46 | - $this->getEntityManager()->getConnection() |
|
46 | + $this->getEntityManager()->getConnection() |
|
47 | 47 | ->executeQuery('COMMIT', $params); |
48 | 48 | } catch (\Exception $e) { |
49 | - $this->getEntityManager()->getConnection() |
|
49 | + $this->getEntityManager()->getConnection() |
|
50 | 50 | ->executeQuery('ROLLBACK', $params); |
51 | 51 | |
52 | - throw new \Exception($e->getMessage()); |
|
52 | + throw new \Exception($e->getMessage()); |
|
53 | + } |
|
53 | 54 | } |
54 | - } |
|
55 | 55 | |
56 | - public function getKeyValuesByPeople(People $people, string $key): ?array |
|
57 | - { |
|
56 | + public function getKeyValuesByPeople(People $people, string $key): ?array |
|
57 | + { |
|
58 | 58 | $result = $this->createQueryBuilder('a') |
59 | - ->andWhere('a.people = :people') |
|
60 | - ->andWhere('a.configKey LIKE :prefix') |
|
61 | - ->setParameter('people', $people) |
|
62 | - ->setParameter('prefix', $key . '-%') |
|
59 | + ->andWhere('a.people = :people') |
|
60 | + ->andWhere('a.configKey LIKE :prefix') |
|
61 | + ->setParameter('people', $people) |
|
62 | + ->setParameter('prefix', $key . '-%') |
|
63 | 63 | |
64 | - ->getQuery() |
|
65 | - ->getResult(); |
|
64 | + ->getQuery() |
|
65 | + ->getResult(); |
|
66 | 66 | |
67 | 67 | if (empty($result)) |
68 | - return null; |
|
68 | + return null; |
|
69 | 69 | |
70 | 70 | $configs = []; |
71 | 71 | |
@@ -73,34 +73,34 @@ discard block |
||
73 | 73 | * @var Config $config |
74 | 74 | */ |
75 | 75 | foreach ($result as $config) { |
76 | - $configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
76 | + $configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $configs; |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | - public function getItauConfigByPeople(People $people): ?array |
|
83 | - { |
|
82 | + public function getItauConfigByPeople(People $people): ?array |
|
83 | + { |
|
84 | 84 | |
85 | 85 | $config = $this->getEntityManager()->getRepository(Config::class)->findOneBy([ |
86 | - 'people' => $people, |
|
87 | - 'configKey' => 'payment_type' |
|
86 | + 'people' => $people, |
|
87 | + 'configKey' => 'payment_type' |
|
88 | 88 | ]); |
89 | 89 | |
90 | 90 | |
91 | 91 | if (empty($config) || $config->getConfigValue() != 'itau') |
92 | - return null; |
|
92 | + return null; |
|
93 | 93 | |
94 | 94 | $result = $this->createQueryBuilder('a') |
95 | - ->andWhere('a.people = :people') |
|
96 | - ->andWhere('a.configKey LIKE :prefix') |
|
97 | - ->setParameter('people', $people) |
|
98 | - ->setParameter('prefix', 'itau-shopline-%') |
|
99 | - ->getQuery() |
|
100 | - ->getResult(); |
|
95 | + ->andWhere('a.people = :people') |
|
96 | + ->andWhere('a.configKey LIKE :prefix') |
|
97 | + ->setParameter('people', $people) |
|
98 | + ->setParameter('prefix', 'itau-shopline-%') |
|
99 | + ->getQuery() |
|
100 | + ->getResult(); |
|
101 | 101 | |
102 | 102 | if (empty($result)) |
103 | - return null; |
|
103 | + return null; |
|
104 | 104 | |
105 | 105 | $configs = []; |
106 | 106 | |
@@ -108,25 +108,25 @@ discard block |
||
108 | 108 | * @var Config $config |
109 | 109 | */ |
110 | 110 | foreach ($result as $config) { |
111 | - $configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
111 | + $configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | return $configs; |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - public function getMauticConfigByPeople(People $people): ?array |
|
118 | - { |
|
117 | + public function getMauticConfigByPeople(People $people): ?array |
|
118 | + { |
|
119 | 119 | $result = $this->createQueryBuilder('a') |
120 | - ->andWhere('a.people = :people') |
|
121 | - ->andWhere('a.configKey LIKE :prefix') |
|
122 | - ->setParameter('people', $people) |
|
123 | - ->setParameter('prefix', 'mautic-%') |
|
120 | + ->andWhere('a.people = :people') |
|
121 | + ->andWhere('a.configKey LIKE :prefix') |
|
122 | + ->setParameter('people', $people) |
|
123 | + ->setParameter('prefix', 'mautic-%') |
|
124 | 124 | |
125 | - ->getQuery() |
|
126 | - ->getResult(); |
|
125 | + ->getQuery() |
|
126 | + ->getResult(); |
|
127 | 127 | |
128 | 128 | if (empty($result)) |
129 | - return null; |
|
129 | + return null; |
|
130 | 130 | |
131 | 131 | $configs = []; |
132 | 132 | |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | * @var Config $config |
135 | 135 | */ |
136 | 136 | foreach ($result as $config) { |
137 | - $configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
137 | + $configs[$config->getConfigKey()] = $config->getConfigValue(); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return $configs; |
141 | - } |
|
141 | + } |
|
142 | 142 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | try { |
18 | 18 | $this->logger->info('Attempting to push message', ['data' => $data, 'topic' => $topic]); |
19 | 19 | |
20 | - $webSocketClient = new Client('localhost', '8080'); |
|
20 | + $webSocketClient = new Client('localhost', '8080'); |
|
21 | 21 | $webSocketClient->connect(); |
22 | 22 | $webSocketClient->publish($topic, json_encode($data)); |
23 | 23 | $webSocketClient->disconnect(); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $this->manager = $entityManager; |
36 | 36 | } |
37 | 37 | |
38 | - public function __invoke(File $data, Request $request) |
|
38 | + public function __invoke(File $data, Request $request) |
|
39 | 39 | { |
40 | 40 | |
41 | 41 | try { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | $content = $file->getContent(); |
49 | - $response = new StreamedResponse(function () use ($content) { |
|
49 | + $response = new StreamedResponse(function() use ($content) { |
|
50 | 50 | fputs(fopen('php://output', 'wb'), $content); |
51 | 51 | }); |
52 | 52 |
@@ -41,8 +41,9 @@ discard block |
||
41 | 41 | try { |
42 | 42 | $file = $data; |
43 | 43 | //$file = $this->manager->getRepository(File::class)->findOneBy(['url' => $request->getPathInfo()]); |
44 | - if (!$file) |
|
45 | - throw new \Exception('Not found', 404); |
|
44 | + if (!$file) { |
|
45 | + throw new \Exception('Not found', 404); |
|
46 | + } |
|
46 | 47 | |
47 | 48 | |
48 | 49 | $content = $file->getContent(); |
@@ -58,10 +59,11 @@ discard block |
||
58 | 59 | $response->headers->set('Content-Type', "$fileType/$ext"); |
59 | 60 | } |
60 | 61 | |
61 | - if ($fileType == 'image') |
|
62 | - $disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_INLINE, basename($request->getPathInfo())); |
|
63 | - else |
|
64 | - $disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, basename($request->getPathInfo())); |
|
62 | + if ($fileType == 'image') { |
|
63 | + $disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_INLINE, basename($request->getPathInfo())); |
|
64 | + } else { |
|
65 | + $disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, basename($request->getPathInfo())); |
|
66 | + } |
|
65 | 67 | |
66 | 68 | $response->headers->set('Content-Disposition', $disposition); |
67 | 69 |