src/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/ExpandProjectionParser.php
/**
     * Modify the 'Projection Tree' to include selection details
     * 
     * @param array(array(string)) $selectPathSegments Collection of select 
     *                                                 paths.
     * 
     * @return void
     * 
     * @throws ODataException If any error occurs while processing select
     *                        path segments
     */
Modify the 'Projection Tree' to include selection details

@param array(array(string)) $selectPathSegments Collection of select
paths.

@return void

@throws ODataException If any error occurs while processing select
path segments
Modify the ' Projection Tree ' to include selection details @param array ( array ( string )) $selectPathSegments Collection of select paths . @return void @throws ODataException If any error occurs while processing select path segments
private function _applySelectionToProjectionTree($selectPathSegments)
    {
        foreach ($selectPathSegments as $selectSubPathSegments) {
            $currentNode = $this->_rootProjectionNode;
            $subPathCount = count($selectSubPathSegments);
            foreach ($selectSubPathSegments as $index => $selectSubPathSegment) {
                if (!($currentNode instanceof RootProjectionNode) 
                    && !($currentNode instanceof ExpandedProjectionNode)
                ) {
					throw ODataException::createBadRequestError(
                        Messages::expandProjectionParserPropertyWithoutMatchingExpand(
                            $currentNode->getPropertyName()
                        )
                    );   
                }
                $currentNode->setSelectionFound();
                $isLastSegment = ($index == $subPathCount - 1);
                if ($selectSubPathSegment === '*') {
                    $currentNode->setSelectAllImmediateProperties();
                    break;
                }
                $currentResourceType = $currentNode->getResourceType();
                $resourceProperty 
                    = $currentResourceType->resolveProperty(
                        $selectSubPathSegment
                    );
                if (is_null($resourceProperty)) {
                    throw ODataException::createSyntaxError(
                        Messages::expandProjectionParserPropertyNotFound(
                            $currentResourceType->getFullName(), 
                            $selectSubPathSegment, 
                            true
                        )
                    );
                }
                if (!$isLastSegment) {
                    if ($resourceProperty->isKindOf(ResourcePropertyKind::BAG)) {
						throw ODataException::createBadRequestError(
                            Messages::expandProjectionParserBagPropertyAsInnerSelectSegment(
                                $currentResourceType->getFullName(), 
                                $selectSubPathSegment
                            )
                        );
                    } else if ($resourceProperty->isKindOf(ResourcePropertyKind::PRIMITIVE)) {
						throw ODataException::createBadRequestError(
                            Messages::expandProjectionParserPrimitivePropertyUsedAsNavigationProperty(
                                $currentResourceType->getFullName(), 
                                $selectSubPathSegment
                            )
                        );
                    } else if ($resourceProperty->isKindOf(ResourcePropertyKind::COMPLEX_TYPE)) {
						throw ODataException::createBadRequestError(
                            Messages::expandProjectionParserComplexPropertyAsInnerSelectSegment(
                                $currentResourceType->getFullName(), 
                                $selectSubPathSegment
                            )
                        );
                    } else if ($resourceProperty->getKind() != ResourcePropertyKind::RESOURCE_REFERENCE && $resourceProperty->getKind() != ResourcePropertyKind::RESOURCESET_REFERENCE) {
                        throw ODataException::createInternalServerError(
                            Messages::expandProjectionParserUnexpectedPropertyType()
                        );
                    }
                }
                $node = $currentNode->findNode($selectSubPathSegment);
                if (is_null($node)) {
                    if (!$isLastSegment) {
						throw ODataException::createBadRequestError(
                            Messages::expandProjectionParserPropertyWithoutMatchingExpand(
                                $selectSubPathSegment
                            )
                        );
                    }
                    $node = new ProjectionNode($selectSubPathSegment, $resourceProperty);
                    $currentNode->addNode($node);
                }
                $currentNode = $node;
                if ($currentNode instanceof ExpandedProjectionNode 
                    && $isLastSegment
                ) {
                    $currentNode->setSelectionFound();
                    $currentNode->markSubtreeAsSelected();
                }
            }
        }
    }
private function _applySelectionToProjectionTree ( $ selectPathSegments ) { foreach ( $ selectPathSegments as $ selectSubPathSegments ) { $ currentNode = $ this -> _rootProjectionNode ; $ subPathCount = count ( $ selectSubPathSegments ) ; foreach ( $ selectSubPathSegments as $ index => $ selectSubPathSegment ) { if ( ! ( $ currentNode instanceof RootProjectionNode ) && ! ( $ currentNode instanceof ExpandedProjectionNode ) ) { throw ODataException :: createBadRequestError ( Messages :: expandProjectionParserPropertyWithoutMatchingExpand ( $ currentNode -> getPropertyName ( ) ) ) ; } $ currentNode -> setSelectionFound ( ) ; $ isLastSegment = ( $ index == $ subPathCount - 1 ) ; if ( $ selectSubPathSegment === '*' ) { $ currentNode -> setSelectAllImmediateProperties ( ) ; break ; } $ currentResourceType = $ currentNode -> getResourceType ( ) ; $ resourceProperty = $ currentResourceType -> resolveProperty ( $ selectSubPathSegment ) ; if ( is_null ( $ resourceProperty ) ) { throw ODataException :: createSyntaxError ( Messages :: expandProjectionParserPropertyNotFound ( $ currentResourceType -> getFullName ( ) , $ selectSubPathSegment , true ) ) ; } if ( ! $ isLastSegment ) { if ( $ resourceProperty -> isKindOf ( ResourcePropertyKind :: BAG ) ) { throw ODataException :: createBadRequestError ( Messages :: expandProjectionParserBagPropertyAsInnerSelectSegment ( $ currentResourceType -> getFullName ( ) , $ selectSubPathSegment ) ) ; } else if ( $ resourceProperty -> isKindOf ( ResourcePropertyKind :: PRIMITIVE ) ) { throw ODataException :: createBadRequestError ( Messages :: expandProjectionParserPrimitivePropertyUsedAsNavigationProperty ( $ currentResourceType -> getFullName ( ) , $ selectSubPathSegment ) ) ; } else if ( $ resourceProperty -> isKindOf ( ResourcePropertyKind :: COMPLEX_TYPE ) ) { throw ODataException :: createBadRequestError ( Messages :: expandProjectionParserComplexPropertyAsInnerSelectSegment ( $ currentResourceType -> getFullName ( ) , $ selectSubPathSegment ) ) ; } else if ( $ resourceProperty -> getKind ( ) != ResourcePropertyKind :: RESOURCE_REFERENCE && $ resourceProperty -> getKind ( ) != ResourcePropertyKind :: RESOURCESET_REFERENCE ) { throw ODataException :: createInternalServerError ( Messages :: expandProjectionParserUnexpectedPropertyType ( ) ) ; } } $ node = $ currentNode -> findNode ( $ selectSubPathSegment ) ; if ( is_null ( $ node ) ) { if ( ! $ isLastSegment ) { throw ODataException :: createBadRequestError ( Messages :: expandProjectionParserPropertyWithoutMatchingExpand ( $ selectSubPathSegment ) ) ; } $ node = new ProjectionNode ( $ selectSubPathSegment , $ resourceProperty ) ; $ currentNode -> addNode ( $ node ) ; } $ currentNode = $ node ; if ( $ currentNode instanceof ExpandedProjectionNode && $ isLastSegment ) { $ currentNode -> setSelectionFound ( ) ; $ currentNode -> markSubtreeAsSelected ( ) ; } } } }
Modify the 'Projection Tree' to include selection details
Modify the ' Projection Tree ' to include selection details