| @@ 509-565 (lines=57) @@ | ||
| 506 | if (is_array($result)) { |
|
| 507 | foreach ($result as $entry) { |
|
| 508 | // Check for null entry |
|
| 509 | if ($isCollection) { |
|
| 510 | $currentResourceSet = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 511 | $resourceSetOfProjectedProperty = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 512 | $projectedProperty1 = $expandedProjectionNode->getResourceProperty(); |
|
| 513 | $result1 = $this->providers->getRelatedResourceSet( |
|
| 514 | QueryType::ENTITIES(), //it's always entities for an expansion |
|
| 515 | $currentResourceSet, |
|
| 516 | $entry, |
|
| 517 | $resourceSetOfProjectedProperty, |
|
| 518 | $projectedProperty1, |
|
| 519 | null, // $filter |
|
| 520 | null, // $orderby |
|
| 521 | null, // $top |
|
| 522 | null // $skip |
|
| 523 | )->results; |
|
| 524 | if (!empty($result1)) { |
|
| 525 | $internalOrderByInfo = $expandedProjectionNode->getInternalOrderByInfo(); |
|
| 526 | if (!is_null($internalOrderByInfo)) { |
|
| 527 | $orderByFunction = $internalOrderByInfo->getSorterFunction()->getReference(); |
|
| 528 | usort($result1, $orderByFunction); |
|
| 529 | unset($internalOrderByInfo); |
|
| 530 | $takeCount = $expandedProjectionNode->getTakeCount(); |
|
| 531 | if (!is_null($takeCount)) { |
|
| 532 | $result1 = array_slice($result1, 0, $takeCount); |
|
| 533 | } |
|
| 534 | } |
|
| 535 | ||
| 536 | $entry->$expandedPropertyName = $result1; |
|
| 537 | $projectedProperty = $expandedProjectionNode->getResourceProperty(); |
|
| 538 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 539 | $projectedProperty |
|
| 540 | ); |
|
| 541 | $this->_executeExpansion($result1); |
|
| 542 | $this->_popSegment($needPop); |
|
| 543 | } else { |
|
| 544 | $entry->$expandedPropertyName = array(); |
|
| 545 | } |
|
| 546 | } else { |
|
| 547 | $currentResourceSet1 = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 548 | $resourceSetOfProjectedProperty1 = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 549 | $projectedProperty2 = $expandedProjectionNode->getResourceProperty(); |
|
| 550 | $result1 = $this->providers->getRelatedResourceReference( |
|
| 551 | $currentResourceSet1, |
|
| 552 | $entry, |
|
| 553 | $resourceSetOfProjectedProperty1, |
|
| 554 | $projectedProperty2 |
|
| 555 | ); |
|
| 556 | $entry->$expandedPropertyName = $result1; |
|
| 557 | if (!is_null($result1)) { |
|
| 558 | $projectedProperty3 = $expandedProjectionNode->getResourceProperty(); |
|
| 559 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 560 | $projectedProperty3 |
|
| 561 | ); |
|
| 562 | $this->_executeExpansion($result1); |
|
| 563 | $this->_popSegment($needPop); |
|
| 564 | } |
|
| 565 | } |
|
| 566 | } |
|
| 567 | } else { |
|
| 568 | if ($isCollection) { |
|
| @@ 567-625 (lines=59) @@ | ||
| 564 | } |
|
| 565 | } |
|
| 566 | } |
|
| 567 | } else { |
|
| 568 | if ($isCollection) { |
|
| 569 | $currentResourceSet2 = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 570 | $resourceSetOfProjectedProperty2 = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 571 | $projectedProperty4 = $expandedProjectionNode->getResourceProperty(); |
|
| 572 | $result1 = $this->providers->getRelatedResourceSet( |
|
| 573 | QueryType::ENTITIES(), //it's always entities for an expansion |
|
| 574 | $currentResourceSet2, |
|
| 575 | $result, |
|
| 576 | $resourceSetOfProjectedProperty2, |
|
| 577 | $projectedProperty4, |
|
| 578 | null, // $filter |
|
| 579 | null, // $orderby |
|
| 580 | null, // $top |
|
| 581 | null // $skip |
|
| 582 | )->results; |
|
| 583 | if (!empty($result1)) { |
|
| 584 | $internalOrderByInfo = $expandedProjectionNode->getInternalOrderByInfo(); |
|
| 585 | if (!is_null($internalOrderByInfo)) { |
|
| 586 | $orderByFunction = $internalOrderByInfo->getSorterFunction()->getReference(); |
|
| 587 | usort($result1, $orderByFunction); |
|
| 588 | unset($internalOrderByInfo); |
|
| 589 | $takeCount = $expandedProjectionNode->getTakeCount(); |
|
| 590 | if (!is_null($takeCount)) { |
|
| 591 | $result1 = array_slice($result1, 0, $takeCount); |
|
| 592 | } |
|
| 593 | } |
|
| 594 | ||
| 595 | $result->$expandedPropertyName = $result1; |
|
| 596 | $projectedProperty7 = $expandedProjectionNode->getResourceProperty(); |
|
| 597 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 598 | $projectedProperty7 |
|
| 599 | ); |
|
| 600 | $this->_executeExpansion($result1); |
|
| 601 | $this->_popSegment($needPop); |
|
| 602 | } else { |
|
| 603 | $result->$expandedPropertyName = array(); |
|
| 604 | } |
|
| 605 | } else { |
|
| 606 | $currentResourceSet3 = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 607 | $resourceSetOfProjectedProperty3 = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 608 | $projectedProperty5 = $expandedProjectionNode->getResourceProperty(); |
|
| 609 | $result1 = $this->providers->getRelatedResourceReference( |
|
| 610 | $currentResourceSet3, |
|
| 611 | $result, |
|
| 612 | $resourceSetOfProjectedProperty3, |
|
| 613 | $projectedProperty5 |
|
| 614 | ); |
|
| 615 | $result->$expandedPropertyName = $result1; |
|
| 616 | if (!is_null($result1)) { |
|
| 617 | $projectedProperty6 = $expandedProjectionNode->getResourceProperty(); |
|
| 618 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 619 | $projectedProperty6 |
|
| 620 | ); |
|
| 621 | $this->_executeExpansion($result1); |
|
| 622 | $this->_popSegment($needPop); |
|
| 623 | } |
|
| 624 | } |
|
| 625 | } |
|
| 626 | } |
|
| 627 | } |
|
| 628 | ||