1 | <?php |
||
20 | class ApiHandler |
||
21 | { |
||
22 | /** |
||
23 | * |
||
24 | */ |
||
25 | private const MAX_RESULTS = 100; |
||
26 | |||
27 | /** |
||
28 | * @var ViewHandlerInterface |
||
29 | */ |
||
30 | public $viewhandler; |
||
31 | |||
32 | /** |
||
33 | * @var EntityManagerInterface |
||
34 | */ |
||
35 | public $em; |
||
36 | |||
37 | /** |
||
38 | * @var Request |
||
39 | */ |
||
40 | public $request; |
||
41 | |||
42 | /** |
||
43 | * @var |
||
44 | */ |
||
45 | public $repository; |
||
46 | |||
47 | /** |
||
48 | * ApiHandler constructor. |
||
49 | * |
||
50 | * @param RequestStack $requestStack |
||
51 | * @param EntityManagerInterface $em |
||
52 | * @param ViewHandlerInterface $viewHandler |
||
53 | */ |
||
54 | public function __construct(RequestStack $requestStack, EntityManagerInterface $em, ViewHandlerInterface $viewHandler) |
||
60 | |||
61 | /** |
||
62 | * @param string $entity |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function init(string $entity) |
||
73 | |||
74 | /** |
||
75 | * @param array $groups |
||
76 | * @param array $routeParams |
||
77 | * |
||
78 | * @return \Symfony\Component\HttpFoundation\Response |
||
79 | */ |
||
80 | public function collect(array $groups, array $routeParams = array()) |
||
89 | |||
90 | /** |
||
91 | * @param $data |
||
92 | * @param array $groups |
||
93 | * |
||
94 | * @return static |
||
95 | */ |
||
96 | public function createView($data, array $groups) |
||
107 | |||
108 | |||
109 | /** |
||
110 | * @return Pagerfanta |
||
111 | */ |
||
112 | private function getPaginatedResult(): Pagerfanta |
||
128 | |||
129 | |||
130 | /** |
||
131 | * Create final return array with data needed + items per page etc. |
||
132 | * |
||
133 | * @param Pagerfanta $pagerfanta |
||
134 | * |
||
135 | * @return array |
||
136 | */ |
||
137 | public function transformIterator(Pagerfanta $pagerfanta): array |
||
149 | |||
150 | /** |
||
151 | * @return QueryBuilder |
||
152 | */ |
||
153 | public function convertRequest(): QueryBuilder |
||
157 | |||
158 | /** |
||
159 | * @return QueryBuilder |
||
160 | */ |
||
161 | public function getQueryBuilder(): QueryBuilder |
||
167 | } |
||
168 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: