@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | $this->uri = $this->request ? $this->request->getPathInfo() : ''; |
43 | 43 | } |
44 | 44 | |
45 | - public function collection($class, $groups, mixed $arguments = [], int $limit = 0, int $page = 1, array $orderby = []) |
|
45 | + public function collection($class, $groups, mixed $arguments = [], int $limit = 0, int $page = 1, array $orderby = []) |
|
46 | 46 | { |
47 | 47 | $response = $this->getBasicResponse($class); |
48 | 48 | |
49 | - $response['hydra:member'] = $this->getMembers($class, $groups, $arguments, $limit, $page, $orderby); |
|
50 | - $response['hydra:search'] = $this->getSearch($class); |
|
51 | - $response['hydra:totalItems'] = $this->getCount($class, $arguments); |
|
49 | + $response['hydra:member'] = $this->getMembers($class, $groups, $arguments, $limit, $page, $orderby); |
|
50 | + $response['hydra:search'] = $this->getSearch($class); |
|
51 | + $response['hydra:totalItems'] = $this->getCount($class, $arguments); |
|
52 | 52 | |
53 | 53 | return $response; |
54 | 54 | } |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | //$response = $this->getBasicResponse($class); |
59 | 59 | //$response['hydra:search'] = $this->getSearch($class); |
60 | 60 | |
61 | - $response['hydra:member'] = $result; |
|
62 | - $response['hydra:totalItems'] = count($response['hydra:member']); |
|
61 | + $response['hydra:member'] = $result; |
|
62 | + $response['hydra:totalItems'] = count($response['hydra:member']); |
|
63 | 63 | |
64 | 64 | return $response; |
65 | 65 | } |
66 | 66 | |
67 | 67 | public function item($class, $id, $groups) |
68 | 68 | { |
69 | - $data = $this->manager->getRepository($class)->find(preg_replace("/[^0-9]/", "", $id)); |
|
69 | + $data = $this->manager->getRepository($class)->find(preg_replace("/[^0-9]/", "", $id)); |
|
70 | 70 | $analisesSerialized = $this->serializer->serialize($data, 'jsonld', ['groups' => $groups]); |
71 | 71 | return json_decode($analisesSerialized); |
72 | 72 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $className = substr($class, strrpos($class, '\\') + 1); |
77 | 77 | |
78 | 78 | $response['@id'] = '/' . strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $className)) . 's'; |
79 | - $response['@context'] = "/contexts/" . $className; |
|
80 | - $response['@type'] = "hydra:Collection"; |
|
79 | + $response['@context'] = "/contexts/" . $className; |
|
80 | + $response['@type'] = "hydra:Collection"; |
|
81 | 81 | |
82 | 82 | $response['hydra:view'] = [ |
83 | 83 | '@id' => $this->uri, |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | if ($page == 1) |
96 | 96 | $offset = (($page = $this->request->get('page') ?: 1) - 1) * $limit; |
97 | 97 | |
98 | - $data = $this->manager->getRepository($class)->findBy($arguments, $orderby, $limit, $offset); |
|
98 | + $data = $this->manager->getRepository($class)->findBy($arguments, $orderby, $limit, $offset); |
|
99 | 99 | |
100 | 100 | return $this->serialize($data, ['groups' => $groups]); |
101 | 101 | } |
@@ -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 |