1 | <?php |
||
8 | class ResourceHandler implements ResourceHandlerInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var EntityManagerFactoryInterface |
||
12 | */ |
||
13 | private $entityManagerFactory; |
||
14 | /** |
||
15 | * @var ResourceMapperInterface |
||
16 | */ |
||
17 | private $resourceMapper; |
||
18 | /** |
||
19 | * @var EntityManagerInterface |
||
20 | */ |
||
21 | private $entityManager; |
||
22 | /** |
||
23 | * @var string mapped object name for resource |
||
24 | */ |
||
25 | private $objectName; |
||
26 | |||
27 | /** |
||
28 | * ResourceHandler constructor. |
||
29 | * @param EntityManagerFactoryInterface $entityManagerFactory |
||
30 | * @param ResourceMapperInterface $resourceMapper |
||
31 | */ |
||
32 | 6 | public function __construct(EntityManagerFactoryInterface $entityManagerFactory, ResourceMapperInterface $resourceMapper) |
|
37 | |||
38 | /** |
||
39 | * @param string $resourceName |
||
40 | * @return EntityManagerInterface |
||
41 | * @throws \Exception |
||
42 | */ |
||
43 | 5 | private function getEntityManagerForResource(string $resourceName) : EntityManagerInterface |
|
50 | |||
51 | /** |
||
52 | * @param string $resourceName |
||
53 | * @return string |
||
54 | */ |
||
55 | 5 | private function getObjectNameForResource(string $resourceName) : string |
|
59 | |||
60 | /** |
||
61 | * @param string $resourceName |
||
62 | * @throws \Exception |
||
63 | */ |
||
64 | 5 | private function setup(string $resourceName) |
|
69 | |||
70 | /** |
||
71 | * @param string $resourceName |
||
72 | * @param int $id |
||
73 | * @param array|null $filters |
||
74 | * @return mixed |
||
75 | * @throws \Exception |
||
76 | */ |
||
77 | 1 | public function getSingle(string $resourceName, int $id, array $filters = array()) |
|
85 | |||
86 | /** |
||
87 | * @param string $resourceName |
||
88 | * @param array $filters |
||
89 | * @param int $limit |
||
90 | * @param int $offset |
||
91 | * @return array |
||
92 | */ |
||
93 | 1 | public function getCollection(string $resourceName, array $filters = array(), int $limit = 20, int $offset = 0) : array |
|
101 | |||
102 | /** |
||
103 | * @param string $resourceName |
||
104 | * @param array $data |
||
105 | * @return mixed |
||
106 | */ |
||
107 | 1 | public function postSingle(string $resourceName, array $data) |
|
115 | |||
116 | /** |
||
117 | * @param string $resourceName |
||
118 | * @param int $id |
||
119 | * @param array $data |
||
120 | * @return mixed |
||
121 | */ |
||
122 | 1 | public function putSingle(string $resourceName, int $id, array $data) |
|
130 | |||
131 | /** |
||
132 | * @param string $resourceName |
||
133 | * @param int $id |
||
134 | * @return bool |
||
135 | */ |
||
136 | 1 | public function deleteSingle(string $resourceName, int $id) : bool |
|
144 | } |
||
145 |