Complex classes like ProvidersWrapper often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ProvidersWrapper, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 34 | class ProvidersWrapper |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * Holds reference to IMetadataProvider implementation. |
||
| 38 | * |
||
| 39 | * @var IMetadataProvider |
||
| 40 | */ |
||
| 41 | private $metaProvider; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Holds reference to IServiceConfiguration implementation. |
||
| 45 | * |
||
| 46 | * @var IServiceConfiguration |
||
| 47 | */ |
||
| 48 | private $config; |
||
| 49 | |||
| 50 | /* |
||
| 51 | * Holds reference to ProvidersQueryWrapper implementation |
||
| 52 | * |
||
| 53 | * @var ProvidersQueryWrapper |
||
| 54 | */ |
||
| 55 | private $providerWrapper; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Cache for ResourceProperties of a resource type that belongs to a |
||
| 59 | * resource set. An entry (ResourceProperty collection) in this cache |
||
| 60 | * contains only the visible properties of ResourceType. |
||
| 61 | * |
||
| 62 | * @var array<array> |
||
| 63 | */ |
||
| 64 | private $propertyCache = []; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Cache for ResourceSetWrappers. If ResourceSet is invisible value will |
||
| 68 | * be null. |
||
| 69 | * |
||
| 70 | * @var ResourceSetWrapper[] indexed by resource set name |
||
| 71 | */ |
||
| 72 | private $setWrapperCache = []; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Cache for ResourceTypes. |
||
| 76 | * |
||
| 77 | * @var ResourceType[] indexed by resource type name |
||
| 78 | */ |
||
| 79 | private $typeCache = []; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Cache for ResourceAssociationSet. If ResourceAssociationSet is invisible |
||
| 83 | * value will be null. |
||
| 84 | * |
||
| 85 | * @var ResourceAssociationSet[] indexed by name |
||
| 86 | */ |
||
| 87 | private $associationSetCache = []; |
||
|
|
|||
| 88 | |||
| 89 | /** |
||
| 90 | * Creates a new instance of ProvidersWrapper. |
||
| 91 | * |
||
| 92 | * @param IMetadataProvider $meta Reference to IMetadataProvider implementation |
||
| 93 | * @param IQueryProvider $query Reference to IQueryProvider implementation |
||
| 94 | * @param IServiceConfiguration $config Reference to IServiceConfiguration implementation |
||
| 95 | */ |
||
| 96 | public function __construct(IMetadataProvider $meta, IQueryProvider $query, IServiceConfiguration $config) |
||
| 97 | { |
||
| 98 | $this->metaProvider = $meta; |
||
| 99 | $this->config = $config; |
||
| 100 | $this->providerWrapper = new ProvidersQueryWrapper($query); |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @return ProvidersQueryWrapper |
||
| 105 | */ |
||
| 106 | public function getProviderWrapper() |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @return IMetadataProvider |
||
| 114 | */ |
||
| 115 | public function getMetaProvider() |
||
| 116 | { |
||
| 117 | assert(null != $this->metaProvider, 'Metadata provider must be set'); |
||
| 118 | return $this->metaProvider; |
||
| 119 | } |
||
| 120 | |||
| 121 | //Wrappers for IMetadataProvider methods |
||
| 122 | |||
| 123 | /** |
||
| 124 | * To get the Container name for the data source, |
||
| 125 | * Note: Wrapper for IMetadataProvider::getContainerName method |
||
| 126 | * implementation. |
||
| 127 | * |
||
| 128 | * @throws ODataException Exception if implementation returns empty container name |
||
| 129 | * |
||
| 130 | * @return string that contains the name of the container |
||
| 131 | */ |
||
| 132 | public function getContainerName() |
||
| 133 | { |
||
| 134 | $containerName = $this->getMetaProvider()->getContainerName(); |
||
| 135 | if (empty($containerName)) { |
||
| 136 | throw new ODataException( |
||
| 137 | Messages::providersWrapperContainerNameMustNotBeNullOrEmpty(), |
||
| 138 | 500 |
||
| 139 | ); |
||
| 140 | } |
||
| 141 | |||
| 142 | return $containerName; |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * To get Namespace name for the data source, |
||
| 147 | * Note: Wrapper for IMetadataProvider::getContainerNamespace method implementation. |
||
| 148 | * |
||
| 149 | * @throws ODataException Exception if implementation returns empty container namespace |
||
| 150 | * |
||
| 151 | * @return string that contains the namespace name |
||
| 152 | */ |
||
| 153 | public function getContainerNamespace() |
||
| 154 | { |
||
| 155 | $containerNamespace = $this->getMetaProvider()->getContainerNamespace(); |
||
| 156 | if (empty($containerNamespace)) { |
||
| 157 | throw new ODataException( |
||
| 158 | Messages::providersWrapperContainerNamespaceMustNotBeNullOrEmpty(), |
||
| 159 | 500 |
||
| 160 | ); |
||
| 161 | } |
||
| 162 | |||
| 163 | return $containerNamespace; |
||
| 164 | } |
||
| 165 | |||
| 166 | /** |
||
| 167 | * To get the data service configuration. |
||
| 168 | * |
||
| 169 | * @return IServiceConfiguration |
||
| 170 | */ |
||
| 171 | public function getConfiguration() |
||
| 172 | { |
||
| 173 | return $this->config; |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | * To get all entity set information, |
||
| 178 | * Note: Wrapper for IMetadataProvider::getResourceSets method implementation, |
||
| 179 | * This method returns array of ResourceSetWrapper instances but the corresponding IDSMP method |
||
| 180 | * returns array of ResourceSet instances. |
||
| 181 | * |
||
| 182 | * @throws ODataException when two resource sets with the same name are encountered |
||
| 183 | * |
||
| 184 | * @return ResourceSetWrapper[] The ResourceSetWrappers for the visible ResourceSets |
||
| 185 | */ |
||
| 186 | public function getResourceSets() |
||
| 187 | { |
||
| 188 | $resourceSets = $this->getMetaProvider()->getResourceSets(); |
||
| 189 | $resourceSetWrappers = []; |
||
| 190 | $resourceSetNames = []; |
||
| 191 | foreach ($resourceSets as $resourceSet) { |
||
| 192 | $name = $resourceSet->getName(); |
||
| 193 | if (in_array($name, $resourceSetNames)) { |
||
| 194 | throw new ODataException(Messages::providersWrapperEntitySetNameShouldBeUnique($name), 500); |
||
| 195 | } |
||
| 196 | |||
| 197 | $resourceSetNames[] = $name; |
||
| 198 | $resourceSetWrapper = $this->validateResourceSetAndGetWrapper($resourceSet); |
||
| 199 | if (null !== $resourceSetWrapper) { |
||
| 200 | $resourceSetWrappers[] = $resourceSetWrapper; |
||
| 201 | } |
||
| 202 | } |
||
| 203 | |||
| 204 | return $resourceSetWrappers; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * This function perform the following operations |
||
| 209 | * (1) If the cache contain an entry [key, value] for the resourceset then |
||
| 210 | * return the entry-value |
||
| 211 | * (2) If the cache not contain an entry for the resourceset then validate |
||
| 212 | * the resourceset |
||
| 213 | * (a) If valid add entry as [resouceset_name, resourceSetWrapper] |
||
| 214 | * (b) if not valid add entry as [resouceset_name, null] |
||
| 215 | * Note: validating a resourceset means checking the resourceset is visible |
||
| 216 | * or not using configuration. |
||
| 217 | * |
||
| 218 | * @param ResourceSet $resourceSet The resourceset to validate and get the |
||
| 219 | * wrapper for |
||
| 220 | * |
||
| 221 | * @return ResourceSetWrapper|null Returns an instance if a resource set with the given name is visible |
||
| 222 | */ |
||
| 223 | private function validateResourceSetAndWrapper(ResourceSet $resourceSet) |
||
| 224 | { |
||
| 225 | $cacheKey = $resourceSet->getName(); |
||
| 226 | if (array_key_exists($cacheKey, $this->setWrapperCache)) { |
||
| 227 | return $this->setWrapperCache[$cacheKey]; |
||
| 228 | } |
||
| 229 | |||
| 230 | $this->validateResourceType($resourceSet->getResourceType()); |
||
| 231 | $wrapper = new ResourceSetWrapper($resourceSet, $this->config); |
||
| 232 | $nuVal = $wrapper->isVisible() ? $wrapper : null; |
||
| 233 | $this->setWrapperCache[$cacheKey] = $nuVal; |
||
| 234 | |||
| 235 | return $this->setWrapperCache[$cacheKey]; |
||
| 236 | } |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Validates the given instance of ResourceType. |
||
| 240 | * |
||
| 241 | * @param ResourceType $resourceType The ResourceType to validate |
||
| 242 | * |
||
| 243 | * @throws ODataException Exception if $resourceType is invalid |
||
| 244 | * |
||
| 245 | * @return ResourceType |
||
| 246 | */ |
||
| 247 | private function validateResourceType(ResourceType $resourceType) |
||
| 248 | { |
||
| 249 | $cacheKey = $resourceType->getName(); |
||
| 250 | if (array_key_exists($cacheKey, $this->typeCache)) { |
||
| 251 | return $this->typeCache[$cacheKey]; |
||
| 252 | } |
||
| 253 | |||
| 254 | //TODO: Do validation if any for the ResourceType |
||
| 255 | $this->typeCache[$cacheKey] = $resourceType; |
||
| 256 | |||
| 257 | return $resourceType; |
||
| 258 | } |
||
| 259 | |||
| 260 | /** |
||
| 261 | * To get all resource types in the data source, |
||
| 262 | * Note: Wrapper for IMetadataProvider::getTypes method implementation. |
||
| 263 | * |
||
| 264 | * @throws ODataException |
||
| 265 | * @return ResourceType[] |
||
| 266 | */ |
||
| 267 | public function getTypes() |
||
| 268 | { |
||
| 269 | $resourceTypes = $this->getMetaProvider()->getTypes(); |
||
| 270 | $resourceTypeNames = []; |
||
| 271 | foreach ($resourceTypes as $resourceType) { |
||
| 272 | if (in_array($resourceType->getName(), $resourceTypeNames)) { |
||
| 273 | throw new ODataException( |
||
| 274 | Messages::providersWrapperEntityTypeNameShouldBeUnique($resourceType->getName()), |
||
| 275 | 500 |
||
| 276 | ); |
||
| 277 | } |
||
| 278 | |||
| 279 | $resourceTypeNames[] = $resourceType->getName(); |
||
| 280 | $this->validateResourceType($resourceType); |
||
| 281 | } |
||
| 282 | |||
| 283 | return $resourceTypes; |
||
| 284 | } |
||
| 285 | |||
| 286 | public function getSingletons() |
||
| 287 | { |
||
| 288 | $singletons = $this->getMetaProvider()->getSingletons(); |
||
| 289 | return (null == $singletons) ? [] : $singletons; |
||
| 290 | } |
||
| 291 | |||
| 292 | /** |
||
| 293 | * To get a resource set based on the specified resource set name which is |
||
| 294 | * visible, |
||
| 295 | * Note: Wrapper for IMetadataProvider::resolveResourceSet method |
||
| 296 | * implementation. |
||
| 297 | * |
||
| 298 | * @param string $name Name of the resource set |
||
| 299 | * |
||
| 300 | * @return ResourceSetWrapper|null Returns resource set with the given name if found, |
||
| 301 | * NULL if resource set is set to invisible or not found |
||
| 302 | */ |
||
| 303 | public function resolveResourceSet($name) |
||
| 304 | { |
||
| 305 | if (array_key_exists($name, $this->setWrapperCache)) { |
||
| 306 | return $this->setWrapperCache[$name]; |
||
| 307 | } |
||
| 308 | |||
| 309 | $resourceSet = $this->getMetaProvider()->resolveResourceSet($name); |
||
| 310 | if (null === $resourceSet) { |
||
| 311 | return null; |
||
| 312 | } |
||
| 313 | |||
| 314 | return $this->validateResourceSetAndWrapper($resourceSet); |
||
| 315 | } |
||
| 316 | |||
| 317 | /** |
||
| 318 | * To get a resource type based on the resource set name, |
||
| 319 | * Note: Wrapper for IMetadataProvider::resolveResourceType |
||
| 320 | * method implementation. |
||
| 321 | * |
||
| 322 | * @param string $name Name of the resource set |
||
| 323 | * |
||
| 324 | * @throws ODataException If the ResourceType is invalid |
||
| 325 | * |
||
| 326 | * @return ResourceType|null resource type with the given resource set name if found else NULL |
||
| 327 | */ |
||
| 328 | public function resolveResourceType($name) |
||
| 329 | { |
||
| 330 | $resourceType = $this->getMetaProvider()->resolveResourceType($name); |
||
| 331 | if (null === $resourceType) { |
||
| 332 | return null; |
||
| 333 | } |
||
| 334 | |||
| 335 | return $this->validateResourceType($resourceType); |
||
| 336 | } |
||
| 337 | |||
| 338 | /** |
||
| 339 | * Try to resolve named singleton. |
||
| 340 | * |
||
| 341 | * @param string $name |
||
| 342 | * @return mixed|null |
||
| 343 | */ |
||
| 344 | public function resolveSingleton($name) |
||
| 345 | { |
||
| 346 | $singletons = $this->getMetaProvider()->getSingletons(); |
||
| 347 | if (array_key_exists($name, $singletons)) { |
||
| 348 | return $singletons[$name]; |
||
| 349 | } |
||
| 350 | return null; |
||
| 351 | } |
||
| 352 | |||
| 353 | /** |
||
| 354 | * The method must return a collection of all the types derived from |
||
| 355 | * $resourceType The collection returned should NOT include the type |
||
| 356 | * passed in as a parameter |
||
| 357 | * Note: Wrapper for IMetadataProvider::getDerivedTypes |
||
| 358 | * method implementation. |
||
| 359 | * |
||
| 360 | * @param ResourceEntityType $resourceType Resource to get derived resource types from |
||
| 361 | * |
||
| 362 | * @throws InvalidOperationException when the meat provider doesn't return an array |
||
| 363 | * |
||
| 364 | * @return ResourceType[] |
||
| 365 | */ |
||
| 366 | public function getDerivedTypes(ResourceEntityType $resourceType) |
||
| 367 | { |
||
| 368 | $derivedTypes = $this->getMetaProvider()->getDerivedTypes($resourceType); |
||
| 369 | if (!is_array($derivedTypes)) { |
||
| 370 | throw new InvalidOperationException( |
||
| 371 | Messages::metadataAssociationTypeSetInvalidGetDerivedTypesReturnType($resourceType->getName()) |
||
| 372 | ); |
||
| 373 | } |
||
| 374 | |||
| 375 | foreach ($derivedTypes as $derivedType) { |
||
| 376 | $this->validateResourceType($derivedType); |
||
| 377 | } |
||
| 378 | |||
| 379 | return $derivedTypes; |
||
| 380 | } |
||
| 381 | |||
| 382 | /** |
||
| 383 | * Returns true if $resourceType represents an Entity Type which has derived |
||
| 384 | * Entity Types, else false. |
||
| 385 | * Note: Wrapper for IMetadataProvider::hasDerivedTypes method implementation. |
||
| 386 | * |
||
| 387 | * @param ResourceEntityType $resourceType Resource to check for derived resource types |
||
| 388 | * |
||
| 389 | * @throws ODataException If the ResourceType is invalid |
||
| 390 | * |
||
| 391 | * @return bool |
||
| 392 | */ |
||
| 393 | public function hasDerivedTypes(ResourceEntityType $resourceType) |
||
| 394 | { |
||
| 395 | $this->validateResourceType($resourceType); |
||
| 396 | |||
| 397 | return $this->getMetaProvider()->hasDerivedTypes($resourceType); |
||
| 398 | } |
||
| 399 | |||
| 400 | /** |
||
| 401 | * Gets the visible resource properties for the given resource type from the given resource set wrapper. |
||
| 402 | * |
||
| 403 | * @param ResourceSetWrapper $setWrapper Resource set wrapper in question |
||
| 404 | * @param ResourceType $resourceType Resource type in question |
||
| 405 | * |
||
| 406 | * @return ResourceProperty[] Collection of visible resource properties from the given resource set wrapper |
||
| 407 | * and resource type |
||
| 408 | */ |
||
| 409 | public function getResourceProperties(ResourceSetWrapper $setWrapper, ResourceType $resourceType) |
||
| 410 | { |
||
| 411 | if (!$resourceType instanceof ResourceEntityType) { |
||
| 412 | //Complex resource type |
||
| 413 | return $resourceType->getAllProperties(); |
||
| 414 | } |
||
| 415 | //TODO: move this to doctrine annotations |
||
| 416 | $cacheKey = $setWrapper->getName() . '_' . $resourceType->getFullName(); |
||
| 417 | if (!array_key_exists($cacheKey, $this->propertyCache)) { |
||
| 418 | //Fill the cache |
||
| 419 | $this->propertyCache[$cacheKey] = []; |
||
| 420 | foreach ($resourceType->getAllProperties() as $resourceProperty) { |
||
| 421 | $this->propertyCache[$cacheKey][$resourceProperty->getName()] = $resourceProperty; |
||
| 422 | } |
||
| 423 | } |
||
| 424 | |||
| 425 | return $this->propertyCache[$cacheKey]; |
||
| 426 | } |
||
| 427 | |||
| 428 | /** |
||
| 429 | * Gets the target resource set wrapper for the given navigation property, |
||
| 430 | * source resource set wrapper and the source resource type. |
||
| 431 | * |
||
| 432 | * @param ResourceSetWrapper $resourceSetWrapper Source resource set |
||
| 433 | * @param ResourceEntityType $resourceType Source resource type |
||
| 434 | * @param ResourceProperty $navigationResourceProperty Navigation property |
||
| 435 | * |
||
| 436 | * @return ResourceSetWrapper|null Returns instance of ResourceSetWrapper |
||
| 437 | * (describes the entity set and associated configuration) for the |
||
| 438 | * given navigation property. returns NULL if resourceset for the |
||
| 439 | * navigation property is invisible or if metadata provider returns |
||
| 440 | * null resource association set |
||
| 441 | */ |
||
| 442 | public function getResourceSetWrapperForNavigationProperty( |
||
| 466 | |||
| 467 | /** |
||
| 468 | * Gets the ResourceAssociationSet instance for the given source association end, |
||
| 469 | * Note: Wrapper for IMetadataProvider::getResourceAssociationSet |
||
| 470 | * method implementation. |
||
| 471 | * |
||
| 472 | * @param ResourceSet $set Resource set of the source association end |
||
| 473 | * @param ResourceEntityType $type Resource type of the source association end |
||
| 474 | * @param ResourceProperty $property Resource property of the source association end |
||
| 475 | * |
||
| 476 | * @throws ODataException |
||
| 477 | * @return ResourceAssociationSet|null Returns ResourceAssociationSet for the source |
||
| 478 | * association end, NULL if no such |
||
| 479 | * association end or resource set in the |
||
| 480 | * other end of the association is invisible |
||
| 481 | */ |
||
| 482 | public function getResourceAssociationSet( |
||
| 549 | |||
| 550 | /** |
||
| 551 | * Gets the resource type on which the resource property is declared on, |
||
| 552 | * If property is not declared in the given resource type, then this |
||
| 553 | * function drill down to the inheritance hierarchy of the given resource |
||
| 554 | * type to find out the base class in which the property is declared. |
||
| 555 | * |
||
| 556 | * @param ResourceType $type The resource type to start looking |
||
| 557 | * @param ResourceProperty $property The resource property in question |
||
| 558 | * |
||
| 559 | * @return ResourceType|null Returns reference to the ResourceType on which |
||
| 560 | * the $property is declared, NULL if |
||
| 561 | * $property is not declared anywhere |
||
| 562 | * in the inheritance hierarchy |
||
| 563 | */ |
||
| 564 | private function getResourceTypeWherePropertyIsDeclared(ResourceType $type, ResourceProperty $property) |
||
| 576 | |||
| 577 | /** |
||
| 578 | * Wrapper function over _validateResourceSetAndGetWrapper function. |
||
| 579 | * |
||
| 580 | * @param ResourceSet $resourceSet see the comments of _validateResourceSetAndGetWrapper |
||
| 581 | * |
||
| 582 | * @return ResourceSetWrapper|null see the comments of _validateResourceSetAndGetWrapper |
||
| 583 | */ |
||
| 584 | public function validateResourceSetAndGetWrapper(ResourceSet $resourceSet) |
||
| 588 | |||
| 589 | /** |
||
| 590 | * Gets the Edm Schema version compliance to the metadata. |
||
| 591 | * |
||
| 592 | * @return EdmSchemaVersion |
||
| 593 | */ |
||
| 594 | public function getEdmSchemaVersion() |
||
| 599 | |||
| 600 | /** |
||
| 601 | * Gets the underlying custom expression provider, the end developer is |
||
| 602 | * responsible for implementing IExpressionProvider if he choose for. |
||
| 603 | * |
||
| 604 | * @return IExpressionProvider Instance of IExpressionProvider implementation |
||
| 605 | */ |
||
| 606 | public function getExpressionProvider() |
||
| 607 | { |
||
| 608 | return $this->getProviderWrapper()->getExpressionProvider(); |
||
| 609 | } |
||
| 610 | |||
| 611 | /** |
||
| 612 | * Indicates if the QueryProvider can handle ordered paging, this means respecting order, skip, and top parameters |
||
| 613 | * If the query provider can not handle ordered paging, it must return the entire result set and POData will |
||
| 614 | * perform the ordering and paging. |
||
| 615 | * |
||
| 616 | * @return bool True if the query provider can handle ordered paging, false if POData should perform the paging |
||
| 617 | */ |
||
| 618 | public function handlesOrderedPaging() |
||
| 619 | { |
||
| 620 | return $this->getProviderWrapper()->handlesOrderedPaging(); |
||
| 621 | } |
||
| 622 | |||
| 623 | /** |
||
| 624 | * Gets collection of entities belongs to an entity set. |
||
| 625 | * |
||
| 626 | * @param QueryType $queryType Indicates if this is a query for a count, entities, or entities |
||
| 627 | * with a count |
||
| 628 | * @param ResourceSet $resourceSet The entity set containing the entities that need to be fetched |
||
| 629 | * @param FilterInfo|null $filterInfo Represents the $filter parameter of the OData query. |
||
| 630 | * NULL if no $filter specified |
||
| 631 | * @param InternalOrderByInfo|null $orderBy The orderBy information |
||
| 632 | * @param int|null $top The top count |
||
| 633 | * @param int|null $skip The skip count |
||
| 634 | * @param SkipTokenInfo|null $skipToken The skip token |
||
| 635 | * |
||
| 636 | * @return QueryResult |
||
| 637 | */ |
||
| 638 | public function getResourceSet( |
||
| 657 | |||
| 658 | /** |
||
| 659 | * Gets an entity instance from an entity set identified by a key. |
||
| 660 | * |
||
| 661 | * @param ResourceSet $resourceSet The entity set containing the entity to fetch |
||
| 662 | * @param KeyDescriptor $keyDescriptor The key identifying the entity to fetch |
||
| 663 | * |
||
| 664 | * @return object|null Returns entity instance if found, else null |
||
| 665 | */ |
||
| 666 | public function getResourceFromResourceSet(ResourceSet $resourceSet, KeyDescriptor $keyDescriptor) |
||
| 667 | { |
||
| 668 | return $this->getProviderWrapper()->getResourceFromResourceSet($resourceSet, $keyDescriptor); |
||
| 669 | } |
||
| 670 | |||
| 671 | /** |
||
| 672 | * Puts an entity instance to entity set identified by a key. |
||
| 673 | * |
||
| 674 | * @param ResourceSet $resourceSet The entity set containing the entity to update |
||
| 675 | * @param KeyDescriptor $keyDescriptor The key identifying the entity to update |
||
| 676 | * @param mixed $data |
||
| 677 | * |
||
| 678 | * @return bool|null Returns result of executing query |
||
| 679 | */ |
||
| 680 | public function putResource( |
||
| 681 | ResourceSet $resourceSet, |
||
| 682 | KeyDescriptor $keyDescriptor, |
||
| 683 | $data |
||
| 684 | ) { |
||
| 685 | return $this->getProviderWrapper()->putResource( |
||
| 686 | $resourceSet, |
||
| 687 | $keyDescriptor, |
||
| 688 | $data |
||
| 689 | ); |
||
| 690 | } |
||
| 691 | |||
| 692 | /** |
||
| 693 | * Get related resource set for a resource. |
||
| 694 | * |
||
| 695 | * @param QueryType $queryType Indicates if this is a query for a count, entities, or entities |
||
| 696 | * with a count |
||
| 697 | * @param ResourceSet $sourceResourceSet The entity set containing the source entity |
||
| 698 | * @param object $sourceEntity The source entity instance |
||
| 699 | * @param ResourceSet $targetResourceSet The resource set containing the target of the navigation property |
||
| 700 | * @param ResourceProperty $targetProperty The navigation property to retrieve |
||
| 701 | * @param FilterInfo|null $filterInfo Represents the $filter parameter of the OData query. |
||
| 702 | * NULL if no $filter specified |
||
| 703 | * @param mixed|null $orderBy sorted order if we want to get the data in some specific order |
||
| 704 | * @param int|null $top number of records which need to be retrieved |
||
| 705 | * @param int|null $skip number of records which need to be skipped |
||
| 706 | * @param SkipTokenInfo|null $skipToken value indicating what records to skip |
||
| 707 | * |
||
| 708 | * @throws ODataException |
||
| 709 | * |
||
| 710 | * @return QueryResult |
||
| 711 | */ |
||
| 712 | public function getRelatedResourceSet( |
||
| 737 | |||
| 738 | /** |
||
| 739 | * Gets a related entity instance from an entity set identified by a key. |
||
| 740 | * |
||
| 741 | * @param ResourceSet $sourceResourceSet The entity set related to the entity to be fetched |
||
| 742 | * @param object $sourceEntity The related entity instance |
||
| 743 | * @param ResourceSet $targetResourceSet The entity set from which entity needs to be fetched |
||
| 744 | * @param ResourceProperty $targetProperty The metadata of the target property |
||
| 745 | * @param KeyDescriptor $keyDescriptor The key to identify the entity to be fetched |
||
| 746 | * |
||
| 747 | * @return object|null Returns entity instance if found, else null |
||
| 748 | */ |
||
| 749 | public function getResourceFromRelatedResourceSet( |
||
| 764 | |||
| 765 | /** |
||
| 766 | * Get related resource for a resource. |
||
| 767 | * |
||
| 768 | * @param ResourceSet $sourceResourceSet The source resource set |
||
| 769 | * @param object $sourceEntity The source resource |
||
| 770 | * @param ResourceSet $targetResourceSet The resource set of the navigation |
||
| 771 | * property |
||
| 772 | * @param ResourceProperty $targetProperty The navigation property to be |
||
| 773 | * retrieved |
||
| 774 | * |
||
| 775 | * @return object|null The related resource if exists, else null |
||
| 776 | */ |
||
| 777 | public function getRelatedResourceReference( |
||
| 790 | |||
| 791 | /** |
||
| 792 | * Updates a resource. |
||
| 793 | * |
||
| 794 | * @param ResourceSet $sourceResourceSet The entity set containing the source entity |
||
| 795 | * @param object $sourceEntityInstance The source entity instance |
||
| 796 | * @param KeyDescriptor $keyDescriptor The key identifying the entity to fetch |
||
| 797 | * @param object $data the New data for the entity instance |
||
| 798 | * @param bool $shouldUpdate Should undefined values be updated or reset to default |
||
| 799 | * |
||
| 800 | * @return object|null the new resource value if it is assignable, or throw exception for null |
||
| 801 | */ |
||
| 802 | public function updateResource( |
||
| 817 | |||
| 818 | /** |
||
| 819 | * Delete resource from a resource set. |
||
| 820 | * |
||
| 821 | * @param ResourceSet $sourceResourceSet |
||
| 822 | * @param object $sourceEntityInstance |
||
| 823 | * |
||
| 824 | * @return bool true if resources successfully deleted, otherwise false |
||
| 825 | */ |
||
| 826 | public function deleteResource( |
||
| 835 | |||
| 836 | /** |
||
| 837 | * @param ResourceSet $resourceSet The entity set containing the entity to fetch |
||
| 838 | * @param object|null $sourceEntityInstance The source entity instance |
||
| 839 | * @param object $data the New data for the entity instance |
||
| 840 | * |
||
| 841 | * @return object|null returns the newly created model if successful, or null if model creation failed |
||
| 842 | */ |
||
| 843 | public function createResourceforResourceSet( |
||
| 854 | |||
| 855 | /** |
||
| 856 | * Create multiple new resources in a resource set. |
||
| 857 | * @param ResourceSet $sourceResourceSet The entity set containing the entity to fetch |
||
| 858 | * @param object[] $data The new data for the entity instance |
||
| 859 | * |
||
| 860 | * @return object[]|null returns the newly created model if successful, or null if model creation failed |
||
| 861 | */ |
||
| 862 | public function createBulkResourceforResourceSet( |
||
| 871 | |||
| 872 | /** |
||
| 873 | * Updates a group of resources in a resource set. |
||
| 874 | * |
||
| 875 | * @param ResourceSet $sourceResourceSet The entity set containing the source entity |
||
| 876 | * @param object $sourceEntityInstance The source entity instance |
||
| 877 | * @param KeyDescriptor[] $keyDescriptor The key identifying the entity to fetch |
||
| 878 | * @param object[] $data The new data for the entity instances |
||
| 879 | * @param bool $shouldUpdate Should undefined values be updated or reset to default |
||
| 880 | * |
||
| 881 | * @return object[]|null the new resource value if it is assignable, or throw exception for null |
||
| 882 | */ |
||
| 883 | public function updateBulkResource( |
||
| 898 | |||
| 899 | /** |
||
| 900 | * Attaches child model to parent model |
||
| 901 | * |
||
| 902 | * @param ResourceSet $sourceResourceSet |
||
| 903 | * @param object $sourceEntityInstance |
||
| 904 | * @param ResourceSet $targetResourceSet |
||
| 905 | * @param object $targetEntityInstance |
||
| 906 | * @param $navPropName |
||
| 907 | * |
||
| 908 | * @return bool |
||
| 909 | */ |
||
| 910 | public function hookSingleModel( |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Removes child model from parent model |
||
| 928 | * |
||
| 929 | * @param ResourceSet $sourceResourceSet |
||
| 930 | * @param object $sourceEntityInstance |
||
| 931 | * @param ResourceSet $targetResourceSet |
||
| 932 | * @param object $targetEntityInstance |
||
| 933 | * @param $navPropName |
||
| 934 | * |
||
| 935 | * @return bool |
||
| 936 | */ |
||
| 937 | public function unhookSingleModel( |
||
| 952 | |||
| 953 | /** |
||
| 954 | * @return mixed |
||
| 955 | */ |
||
| 956 | public function getMetadataXML() |
||
| 960 | |||
| 961 | /** |
||
| 962 | * Start database transaction |
||
| 963 | * |
||
| 964 | * @return void |
||
| 965 | */ |
||
| 966 | public function startTransaction() |
||
| 970 | |||
| 971 | /** |
||
| 972 | * Commit database transaction |
||
| 973 | * |
||
| 974 | * @return void |
||
| 975 | */ |
||
| 976 | public function commitTransaction() |
||
| 980 | |||
| 981 | /** |
||
| 982 | * Abort database transaction |
||
| 983 | * |
||
| 984 | * @return void |
||
| 985 | */ |
||
| 986 | public function rollBackTransaction() |
||
| 990 | } |
||
| 991 |
This check marks private properties in classes that are never used. Those properties can be removed.