| @@ 669-725 (lines=57) @@ | ||
| 666 | if (is_array($result)) { |
|
| 667 | foreach ($result as $entry) { |
|
| 668 | // Check for null entry |
|
| 669 | if ($isCollection) { |
|
| 670 | $currentResourceSet = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 671 | $resourceSetOfProjectedProperty = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 672 | $projectedProperty1 = $expandedProjectionNode->getResourceProperty(); |
|
| 673 | $result1 = $this->providers->getRelatedResourceSet( |
|
| 674 | QueryType::ENTITIES(), //it's always entities for an expansion |
|
| 675 | $currentResourceSet, |
|
| 676 | $entry, |
|
| 677 | $resourceSetOfProjectedProperty, |
|
| 678 | $projectedProperty1, |
|
| 679 | null, // $filter |
|
| 680 | null, // $orderby |
|
| 681 | null, // $top |
|
| 682 | null // $skip |
|
| 683 | )->results; |
|
| 684 | if (!empty($result1)) { |
|
| 685 | $internalOrderByInfo = $expandedProjectionNode->getInternalOrderByInfo(); |
|
| 686 | if (!is_null($internalOrderByInfo)) { |
|
| 687 | $orderByFunction = $internalOrderByInfo->getSorterFunction()->getReference(); |
|
| 688 | usort($result1, $orderByFunction); |
|
| 689 | unset($internalOrderByInfo); |
|
| 690 | $takeCount = $expandedProjectionNode->getTakeCount(); |
|
| 691 | if (!is_null($takeCount)) { |
|
| 692 | $result1 = array_slice($result1, 0, $takeCount); |
|
| 693 | } |
|
| 694 | } |
|
| 695 | ||
| 696 | $entry->$expandedPropertyName = $result1; |
|
| 697 | $projectedProperty = $expandedProjectionNode->getResourceProperty(); |
|
| 698 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 699 | $projectedProperty |
|
| 700 | ); |
|
| 701 | $this->_executeExpansion($result1); |
|
| 702 | $this->_popSegment($needPop); |
|
| 703 | } else { |
|
| 704 | $entry->$expandedPropertyName = array(); |
|
| 705 | } |
|
| 706 | } else { |
|
| 707 | $currentResourceSet1 = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 708 | $resourceSetOfProjectedProperty1 = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 709 | $projectedProperty2 = $expandedProjectionNode->getResourceProperty(); |
|
| 710 | $result1 = $this->providers->getRelatedResourceReference( |
|
| 711 | $currentResourceSet1, |
|
| 712 | $entry, |
|
| 713 | $resourceSetOfProjectedProperty1, |
|
| 714 | $projectedProperty2 |
|
| 715 | ); |
|
| 716 | $entry->$expandedPropertyName = $result1; |
|
| 717 | if (!is_null($result1)) { |
|
| 718 | $projectedProperty3 = $expandedProjectionNode->getResourceProperty(); |
|
| 719 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 720 | $projectedProperty3 |
|
| 721 | ); |
|
| 722 | $this->_executeExpansion($result1); |
|
| 723 | $this->_popSegment($needPop); |
|
| 724 | } |
|
| 725 | } |
|
| 726 | } |
|
| 727 | } else { |
|
| 728 | if ($isCollection) { |
|
| @@ 727-785 (lines=59) @@ | ||
| 724 | } |
|
| 725 | } |
|
| 726 | } |
|
| 727 | } else { |
|
| 728 | if ($isCollection) { |
|
| 729 | $currentResourceSet2 = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 730 | $resourceSetOfProjectedProperty2 = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 731 | $projectedProperty4 = $expandedProjectionNode->getResourceProperty(); |
|
| 732 | $result1 = $this->providers->getRelatedResourceSet( |
|
| 733 | QueryType::ENTITIES(), //it's always entities for an expansion |
|
| 734 | $currentResourceSet2, |
|
| 735 | $result, |
|
| 736 | $resourceSetOfProjectedProperty2, |
|
| 737 | $projectedProperty4, |
|
| 738 | null, // $filter |
|
| 739 | null, // $orderby |
|
| 740 | null, // $top |
|
| 741 | null // $skip |
|
| 742 | )->results; |
|
| 743 | if (!empty($result1)) { |
|
| 744 | $internalOrderByInfo = $expandedProjectionNode->getInternalOrderByInfo(); |
|
| 745 | if (!is_null($internalOrderByInfo)) { |
|
| 746 | $orderByFunction = $internalOrderByInfo->getSorterFunction()->getReference(); |
|
| 747 | usort($result1, $orderByFunction); |
|
| 748 | unset($internalOrderByInfo); |
|
| 749 | $takeCount = $expandedProjectionNode->getTakeCount(); |
|
| 750 | if (!is_null($takeCount)) { |
|
| 751 | $result1 = array_slice($result1, 0, $takeCount); |
|
| 752 | } |
|
| 753 | } |
|
| 754 | ||
| 755 | $result->$expandedPropertyName = $result1; |
|
| 756 | $projectedProperty7 = $expandedProjectionNode->getResourceProperty(); |
|
| 757 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 758 | $projectedProperty7 |
|
| 759 | ); |
|
| 760 | $this->_executeExpansion($result1); |
|
| 761 | $this->_popSegment($needPop); |
|
| 762 | } else { |
|
| 763 | $result->$expandedPropertyName = array(); |
|
| 764 | } |
|
| 765 | } else { |
|
| 766 | $currentResourceSet3 = $this->_getCurrentResourceSetWrapper()->getResourceSet(); |
|
| 767 | $resourceSetOfProjectedProperty3 = $expandedProjectionNode->getResourceSetWrapper()->getResourceSet(); |
|
| 768 | $projectedProperty5 = $expandedProjectionNode->getResourceProperty(); |
|
| 769 | $result1 = $this->providers->getRelatedResourceReference( |
|
| 770 | $currentResourceSet3, |
|
| 771 | $result, |
|
| 772 | $resourceSetOfProjectedProperty3, |
|
| 773 | $projectedProperty5 |
|
| 774 | ); |
|
| 775 | $result->$expandedPropertyName = $result1; |
|
| 776 | if (!is_null($result1)) { |
|
| 777 | $projectedProperty6 = $expandedProjectionNode->getResourceProperty(); |
|
| 778 | $needPop = $this->_pushSegmentForNavigationProperty( |
|
| 779 | $projectedProperty6 |
|
| 780 | ); |
|
| 781 | $this->_executeExpansion($result1); |
|
| 782 | $this->_popSegment($needPop); |
|
| 783 | } |
|
| 784 | } |
|
| 785 | } |
|
| 786 | } |
|
| 787 | } |
|
| 788 | ||