@@ -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) |
@@ -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 | |
@@ -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 | } |
@@ -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 | |
@@ -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 | |
@@ -51,8 +51,9 @@ |
||
| 51 | 51 | $service = $this->container->get($serviceName); |
| 52 | 52 | if (method_exists($service, $method)) { |
| 53 | 53 | $entity = $service->$method($entity); |
| 54 | - if ('afterPersist' === $method && $entity) |
|
| 55 | - $this->manager->refresh($entity); |
|
| 54 | + if ('afterPersist' === $method && $entity) { |
|
| 55 | + $this->manager->refresh($entity); |
|
| 56 | + } |
|
| 56 | 57 | } |
| 57 | 58 | } |
| 58 | 59 | } |
@@ -38,8 +38,9 @@ |
||
| 38 | 38 | ) |
| 39 | 39 | )); |
| 40 | 40 | |
| 41 | - if (!$domain) |
|
| 42 | - throw new InvalidArgumentException('Please define header or get param "app-domain"', 301); |
|
| 41 | + if (!$domain) { |
|
| 42 | + throw new InvalidArgumentException('Please define header or get param "app-domain"', 301); |
|
| 43 | + } |
|
| 43 | 44 | return $domain; |
| 44 | 45 | } |
| 45 | 46 | |
@@ -24,13 +24,15 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | public function persist($entity) |
| 26 | 26 | { |
| 27 | - if (self::$persisted == true) |
|
| 28 | - return; |
|
| 27 | + if (self::$persisted == true) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 29 | 30 | self::$persisted = true; |
| 30 | 31 | |
| 31 | 32 | $extra_data = json_decode($this->request->getContent(), true)['extra-data'] ?? null; |
| 32 | - if (!$extra_data) |
|
| 33 | - return; |
|
| 33 | + if (!$extra_data) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | //$this->manager->persist($entity); |
| 36 | 38 | //$this->manager->flush(); |
@@ -41,11 +43,13 @@ discard block |
||
| 41 | 43 | } |
| 42 | 44 | private function persistData($entity_id, $entity_name) |
| 43 | 45 | { |
| 44 | - if (!$entity_id || !$entity_name) |
|
| 45 | - return; |
|
| 46 | + if (!$entity_id || !$entity_name) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 46 | 49 | $extra_data = json_decode($this->request->getContent(), true)['extra-data'] ?? null; |
| 47 | - if (!$extra_data) |
|
| 48 | - return; |
|
| 50 | + if (!$extra_data) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 49 | 53 | |
| 50 | 54 | |
| 51 | 55 | foreach ($extra_data['data'] as $key => $data) { |
@@ -57,8 +61,9 @@ discard block |
||
| 57 | 61 | 'extra_fields' => $extra_fields |
| 58 | 62 | ]); |
| 59 | 63 | |
| 60 | - if (!$extraData) |
|
| 61 | - $extraData = new ExtraData(); |
|
| 64 | + if (!$extraData) { |
|
| 65 | + $extraData = new ExtraData(); |
|
| 66 | + } |
|
| 62 | 67 | |
| 63 | 68 | $extraData->setExtraFields($extra_fields); |
| 64 | 69 | $extraData->setEntityName($entity_name); |
@@ -73,13 +78,15 @@ discard block |
||
| 73 | 78 | |
| 74 | 79 | public function noChange() |
| 75 | 80 | { |
| 76 | - if (self::$persisted == true) |
|
| 77 | - return; |
|
| 81 | + if (self::$persisted == true) { |
|
| 82 | + return; |
|
| 83 | + } |
|
| 78 | 84 | self::$persisted = true; |
| 79 | 85 | |
| 80 | 86 | $extra_data = json_decode($this->request->getContent(), true)['extra-data'] ?: null; |
| 81 | - if (!$extra_data) |
|
| 82 | - return; |
|
| 87 | + if (!$extra_data) { |
|
| 88 | + return; |
|
| 89 | + } |
|
| 83 | 90 | |
| 84 | 91 | $this->persistData($extra_data['entity_id'], $extra_data['entity_name']); |
| 85 | 92 | } |