src/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/ExpandProjectionParser.php
/**
     * Build 'Projection Tree' from the given expand path segments
     * 
     * @param array(array(string)) $expandPathSegments Collection of expand paths.
     *
     * 
     * @return void
     * 
     * @throws ODataException If any error occurs while processing the expand path segments
     *                        .
     */
Build 'Projection Tree' from the given expand path segments

@param array(array(string)) $expandPathSegments Collection of expand paths.

@return void

@throws ODataException If any error occurs while processing the expand path segments
.
Build ' Projection Tree ' from the given expand path segments @param array ( array ( string )) $expandPathSegments Collection of expand paths . @return void @throws ODataException If any error occurs while processing the expand path segments .
private function _buildProjectionTree($expandPathSegments)
    {
        foreach ($expandPathSegments as $expandSubPathSegments) {
            $currentNode = $this->_rootProjectionNode;
            foreach ($expandSubPathSegments as $expandSubPathSegment) {
                $resourceSetWrapper = $currentNode->getResourceSetWrapper();
                $resourceType = $currentNode->getResourceType();
                $resourceProperty 
                    = $resourceType->resolveProperty(
                        $expandSubPathSegment
                    );
                if (is_null($resourceProperty)) {
					throw ODataException::createSyntaxError(
                        Messages::expandProjectionParserPropertyNotFound(
                            $resourceType->getFullName(), 
                            $expandSubPathSegment, 
                            false
                        )
                    );
                } else if ($resourceProperty->getTypeKind() != ResourceTypeKind::ENTITY) {
					throw ODataException::createBadRequestError(
                        Messages::expandProjectionParserExpandCanOnlyAppliedToEntity(
                            $resourceType->getFullName(), 
                            $expandSubPathSegment
                        )
                    );
                }
                $resourceSetWrapper = $this->_providerWrapper
                    ->getResourceSetWrapperForNavigationProperty(
                        $resourceSetWrapper, 
                        $resourceType, 
                        $resourceProperty
                    );
                if (is_null($resourceSetWrapper)) {
					throw ODataException::createBadRequestError(
                        Messages::badRequestInvalidPropertyNameSpecified(
                            $resourceType->getFullName(), 
                            $expandSubPathSegment
                        )
                    );
                }
                $singleResult 
                    = $resourceProperty->isKindOf(
                        ResourcePropertyKind::RESOURCE_REFERENCE
                    );
                $resourceSetWrapper->checkResourceSetRightsForRead($singleResult);
                $pageSize = $resourceSetWrapper->getResourceSetPageSize();
                $internalOrderByInfo = null;
                if ($pageSize != 0 && !$singleResult) {
                    $this->_rootProjectionNode->setPagedExpandedResult(true);
                    $rt = $resourceSetWrapper->getResourceType();
                    $keys = array_keys($rt->getKeyProperties());
                    $orderBy = null;
                    foreach ($keys as $key) {
                        $orderBy = $orderBy . $key . ', ';
                    }
                    $orderBy = rtrim($orderBy, ', ');
                    $internalOrderByInfo = OrderByParser::parseOrderByClause(
                        $resourceSetWrapper,
                        $rt,
                        $orderBy,
                        $this->_providerWrapper
                    );
                }
                $node = $currentNode->findNode($expandSubPathSegment);
                if (is_null($node)) {
                    $maxResultCount = $this->_providerWrapper
                        ->getConfiguration()->getMaxResultsPerCollection();
                    $node = new ExpandedProjectionNode(
                        $expandSubPathSegment, 
                        $resourceProperty, 
                        $resourceSetWrapper,
                        $internalOrderByInfo,
                        null, 
                        $pageSize == 0 ? null : $pageSize, 
                        $maxResultCount == PHP_INT_MAX ? null : $maxResultCount
                    );
                    $currentNode->addNode($node);
                }
                $currentNode = $node;
            }
        } 
    }
private function _buildProjectionTree ( $ expandPathSegments ) { foreach ( $ expandPathSegments as $ expandSubPathSegments ) { $ currentNode = $ this -> _rootProjectionNode ; foreach ( $ expandSubPathSegments as $ expandSubPathSegment ) { $ resourceSetWrapper = $ currentNode -> getResourceSetWrapper ( ) ; $ resourceType = $ currentNode -> getResourceType ( ) ; $ resourceProperty = $ resourceType -> resolveProperty ( $ expandSubPathSegment ) ; if ( is_null ( $ resourceProperty ) ) { throw ODataException :: createSyntaxError ( Messages :: expandProjectionParserPropertyNotFound ( $ resourceType -> getFullName ( ) , $ expandSubPathSegment , false ) ) ; } else if ( $ resourceProperty -> getTypeKind ( ) != ResourceTypeKind :: ENTITY ) { throw ODataException :: createBadRequestError ( Messages :: expandProjectionParserExpandCanOnlyAppliedToEntity ( $ resourceType -> getFullName ( ) , $ expandSubPathSegment ) ) ; } $ resourceSetWrapper = $ this -> _providerWrapper -> getResourceSetWrapperForNavigationProperty ( $ resourceSetWrapper , $ resourceType , $ resourceProperty ) ; if ( is_null ( $ resourceSetWrapper ) ) { throw ODataException :: createBadRequestError ( Messages :: badRequestInvalidPropertyNameSpecified ( $ resourceType -> getFullName ( ) , $ expandSubPathSegment ) ) ; } $ singleResult = $ resourceProperty -> isKindOf ( ResourcePropertyKind :: RESOURCE_REFERENCE ) ; $ resourceSetWrapper -> checkResourceSetRightsForRead ( $ singleResult ) ; $ pageSize = $ resourceSetWrapper -> getResourceSetPageSize ( ) ; $ internalOrderByInfo = null ; if ( $ pageSize != 0 && ! $ singleResult ) { $ this -> _rootProjectionNode -> setPagedExpandedResult ( true ) ; $ rt = $ resourceSetWrapper -> getResourceType ( ) ; $ keys = array_keys ( $ rt -> getKeyProperties ( ) ) ; $ orderBy = null ; foreach ( $ keys as $ key ) { $ orderBy = $ orderBy . $ key . ', ' ; } $ orderBy = rtrim ( $ orderBy , ', ' ) ; $ internalOrderByInfo = OrderByParser :: parseOrderByClause ( $ resourceSetWrapper , $ rt , $ orderBy , $ this -> _providerWrapper ) ; } $ node = $ currentNode -> findNode ( $ expandSubPathSegment ) ; if ( is_null ( $ node ) ) { $ maxResultCount = $ this -> _providerWrapper -> getConfiguration ( ) -> getMaxResultsPerCollection ( ) ; $ node = new ExpandedProjectionNode ( $ expandSubPathSegment , $ resourceProperty , $ resourceSetWrapper , $ internalOrderByInfo , null , $ pageSize == 0 ? null : $ pageSize , $ maxResultCount == PHP_INT_MAX ? null : $ maxResultCount ) ; $ currentNode -> addNode ( $ node ) ; } $ currentNode = $ node ; } } }
Build 'Projection Tree' from the given expand path segments
Build ' Projection Tree ' from the given expand path segments
//assert($rt != null) //assert(!empty($keys))