1 | <?php |
||
20 | class ProvidersQueryWrapper |
||
21 | { |
||
22 | /** |
||
23 | * Holds reference to IQueryProvider implementation. |
||
24 | * |
||
25 | * @var IQueryProvider |
||
26 | */ |
||
27 | private $queryProvider; |
||
28 | |||
29 | /** |
||
30 | * Creates a new instance of ProvidersWrapper. |
||
31 | * |
||
32 | * @param IQueryProvider $query Reference to IQueryProvider implementation |
||
33 | */ |
||
34 | public function __construct(IQueryProvider $query) |
||
38 | |||
39 | public function getQueryProvider() |
||
43 | |||
44 | /** |
||
45 | * Get related resource set for a resource. |
||
46 | * |
||
47 | * @param QueryType $queryType Indicates if this is a query for a count, entities, or entities |
||
48 | * with a count |
||
49 | * @param ResourceSet $sourceResourceSet The entity set containing the source entity |
||
50 | * @param object $sourceEntity The source entity instance |
||
51 | * @param ResourceSet $targetResourceSet The resource set containing the target of the navigation property |
||
52 | * @param ResourceProperty $targetProperty The navigation property to retrieve |
||
53 | * @param FilterInfo $filterInfo Represents the $filter parameter of the OData query. |
||
54 | * NULL if no $filter specified |
||
55 | * @param mixed $orderBy sorted order if we want to get the data in some specific order |
||
56 | * @param int $top The top count |
||
57 | * @param int $skip The skip count |
||
58 | * @param SkipTokenInfo|null $skipToken The skip token |
||
59 | * |
||
60 | * @throws ODataException |
||
61 | * |
||
62 | * @return QueryResult |
||
63 | */ |
||
64 | public function getRelatedResourceSet( |
||
93 | |||
94 | /** |
||
95 | * Gets collection of entities belongs to an entity set. |
||
96 | * |
||
97 | * @param QueryType $queryType Indicates if this is a query for a count, entities, or entities with a |
||
98 | * count |
||
99 | * @param ResourceSet $resourceSet The entity set containing the entities that need to be fetched |
||
100 | * @param FilterInfo $filterInfo Represents the $filter parameter of the OData query. |
||
101 | * NULL if no $filter specified |
||
102 | * @param InternalOrderByInfo $orderBy The orderBy information |
||
103 | * @param int $top The top count |
||
104 | * @param int $skip The skip count |
||
105 | * @param SkipTokenInfo|null $skipToken The skip token |
||
106 | * |
||
107 | * @return QueryResult |
||
108 | */ |
||
109 | public function getResourceSet( |
||
132 | |||
133 | /** |
||
134 | * Puts an entity instance to entity set identified by a key. |
||
135 | * |
||
136 | * @param ResourceSet $resourceSet The entity set containing the entity to update |
||
137 | * @param KeyDescriptor $keyDescriptor The key identifying the entity to update |
||
138 | * @param $data |
||
139 | * |
||
140 | * @return bool|null Returns result of executiong query |
||
141 | */ |
||
142 | public function putResource( |
||
155 | |||
156 | /** |
||
157 | * Indicates if the QueryProvider can handle ordered paging, this means respecting order, skip, and top parameters |
||
158 | * If the query provider can not handle ordered paging, it must return the entire result set and POData will |
||
159 | * perform the ordering and paging. |
||
160 | * |
||
161 | * @return bool True if the query provider can handle ordered paging, false if POData should perform the paging |
||
162 | */ |
||
163 | public function handlesOrderedPaging() |
||
167 | |||
168 | /** |
||
169 | * Gets the underlying custom expression provider, the end developer is |
||
170 | * responsible for implementing IExpressionProvider if he choose for. |
||
171 | * |
||
172 | * @throws ODataException |
||
173 | * |
||
174 | * @return IExpressionProvider Instance of IExpressionProvider implementation |
||
175 | */ |
||
176 | public function getExpressionProvider() |
||
193 | |||
194 | /** |
||
195 | * @param ResourceSet $resourceSet The entity set containing the entity to fetch |
||
196 | * @param object $sourceEntityInstance The source entity instance |
||
197 | * @param object $data The New data for the entity instance. |
||
198 | * |
||
199 | * returns object|null returns the newly created model if sucessful or null if model creation failed. |
||
200 | */ |
||
201 | public function createResourceforResourceSet( |
||
212 | |||
213 | /** |
||
214 | * Delete resource from a resource set. |
||
215 | * |
||
216 | * @param ResourceSet $sourceResourceSet |
||
217 | * @param object $sourceEntityInstance |
||
218 | * |
||
219 | * return bool true if resources sucessfully deteled, otherwise false. |
||
220 | */ |
||
221 | public function deleteResource( |
||
230 | |||
231 | /** |
||
232 | * Updates a resource. |
||
233 | * |
||
234 | * @param ResourceSet $sourceResourceSet The entity set containing the source entity |
||
235 | * @param object $sourceEntityInstance The source entity instance |
||
236 | * @param KeyDescriptor $keyDescriptor The key identifying the entity to fetch |
||
237 | * @param object $data The New data for the entity instance. |
||
238 | * @param bool $shouldUpdate Should undefined values be updated or reset to default |
||
239 | * |
||
240 | * @return object|null The new resource value if it is assignable or throw exception for null. |
||
241 | */ |
||
242 | public function updateResource( |
||
257 | |||
258 | /** |
||
259 | * Get related resource for a resource. |
||
260 | * |
||
261 | * @param ResourceSet $sourceResourceSet The source resource set |
||
262 | * @param object $sourceEntity The source resource |
||
263 | * @param ResourceSet $targetResourceSet The resource set of the navigation |
||
264 | * property |
||
265 | * @param ResourceProperty $targetProperty The navigation property to be |
||
266 | * retrieved |
||
267 | * |
||
268 | * @throws ODataException |
||
269 | * |
||
270 | * @return object|null The related resource if exists else null |
||
271 | */ |
||
272 | public function getRelatedResourceReference( |
||
312 | |||
313 | /** |
||
314 | * Gets a related entity instance from an entity set identified by a key. |
||
315 | * |
||
316 | * @param ResourceSet $sourceResourceSet The entity set related to the entity to be fetched |
||
317 | * @param object $sourceEntity The related entity instance |
||
318 | * @param ResourceSet $targetResourceSet The entity set from which entity needs to be fetched |
||
319 | * @param ResourceProperty $targetProperty The metadata of the target property |
||
320 | * @param KeyDescriptor $keyDescriptor The key to identify the entity to be fetched |
||
321 | * |
||
322 | * @return object|null Returns entity instance if found else null |
||
323 | */ |
||
324 | public function getResourceFromRelatedResourceSet( |
||
348 | |||
349 | /** |
||
350 | * Gets an entity instance from an entity set identified by a key. |
||
351 | * |
||
352 | * @param ResourceSet $resourceSet The entity set containing the entity to fetch |
||
353 | * @param KeyDescriptor $keyDescriptor The key identifying the entity to fetch |
||
354 | * |
||
355 | * @return object|null Returns entity instance if found else null |
||
356 | */ |
||
357 | public function getResourceFromResourceSet(ResourceSet $resourceSet, KeyDescriptor $keyDescriptor) |
||
369 | |||
370 | /** |
||
371 | * @param QueryResult $queryResult |
||
372 | * @param string $methodName |
||
373 | * |
||
374 | * @throws ODataException |
||
375 | */ |
||
376 | private function validateQueryResult($queryResult, QueryType $queryType, $methodName) |
||
409 | |||
410 | /** |
||
411 | * Validate the given entity instance. |
||
412 | * |
||
413 | * @param object|null $entityInstance Entity instance to validate |
||
414 | * @param ResourceSet &$resourceSet Resource set to which the entity |
||
415 | * instance belongs to |
||
416 | * @param KeyDescriptor &$keyDescriptor The key descriptor |
||
417 | * @param string $methodName Method from which this function |
||
418 | * invoked |
||
419 | * |
||
420 | * @throws ODataException |
||
421 | */ |
||
422 | private function validateEntityInstance( |
||
454 | |||
455 | /** |
||
456 | * @param string $methodName |
||
457 | * @param $entityInstance |
||
458 | * @param ResourceSet $resourceSet |
||
459 | * |
||
460 | * @throws ODataException |
||
461 | * |
||
462 | * @return ResourceType |
||
463 | */ |
||
464 | private function verifyResourceType($methodName, $entityInstance, ResourceSet $resourceSet) |
||
479 | } |
||
480 |