src/POData/UriProcessor/ResourcePathProcessor/SegmentParser/SegmentParser.php
/**
     * Create SegmentDescriptor for the first segment
     * 
     * @param string $segmentIdentifier The identifier part of the first segment
     * @param string $keyPredicate The predicate part of the first segment if any else NULL
     * @param boolean $checkRights Whether to check the rights on this segment
     *
     * @return SegmentDescriptor Descriptor for the first segment
     * 
     * @throws ODataException Exception if any validation fails
     */
Create SegmentDescriptor for the first segment

@param string $segmentIdentifier The identifier part of the first segment
@param string $keyPredicate The predicate part of the first segment if any else NULL
@param boolean $checkRights Whether to check the rights on this segment

@return SegmentDescriptor Descriptor for the first segment

@throws ODataException Exception if any validation fails
Create SegmentDescriptor for the first segment @param string $segmentIdentifier The identifier part of the first segment @param string $keyPredicate The predicate part of the first segment if any else NULL @param boolean $checkRights Whether to check the rights on this segment @return SegmentDescriptor Descriptor for the first segment @throws ODataException Exception if any validation fails
private function _createFirstSegmentDescriptor($segmentIdentifier, $keyPredicate, $checkRights) {
        $descriptor = new SegmentDescriptor();
        $descriptor->setIdentifier($segmentIdentifier);
        if ($segmentIdentifier === ODataConstants::URI_METADATA_SEGMENT) {
            $this->_assertion(is_null($keyPredicate));            
            $descriptor->setTargetKind(TargetKind::METADATA());
            return $descriptor;
        }
        if ($segmentIdentifier === ODataConstants::URI_BATCH_SEGMENT) {
            $this->_assertion(is_null($keyPredicate));
            $descriptor->setTargetKind(TargetKind::BATCH());
            return $descriptor;
        }
        if ($segmentIdentifier === ODataConstants::URI_COUNT_SEGMENT) {
			throw ODataException::createBadRequestError(
                Messages::segmentParserSegmentNotAllowedOnRoot(
                    ODataConstants::URI_COUNT_SEGMENT
                )
            );
        }
        if ($segmentIdentifier === ODataConstants::URI_LINK_SEGMENT) {
			throw ODataException::createBadRequestError(
                Messages::segmentParserSegmentNotAllowedOnRoot(
                    ODataConstants::URI_LINK_SEGMENT
                )
            );
        }
        $resourceSetWrapper = $this->providerWrapper->resolveResourceSet($segmentIdentifier);
        if ($resourceSetWrapper === null) {
			throw ODataException::createResourceNotFoundError($segmentIdentifier);
        }
        $descriptor->setTargetResourceSetWrapper($resourceSetWrapper);
        $descriptor->setTargetResourceType($resourceSetWrapper->getResourceType());
        $descriptor->setTargetSource(TargetSource::ENTITY_SET);
        $descriptor->setTargetKind(TargetKind::RESOURCE());
        if ($keyPredicate !== null) {
            $keyDescriptor = $this->_createKeyDescriptor(
                $segmentIdentifier . '(' . $keyPredicate . ')', 
                $resourceSetWrapper->getResourceType(), 
                $keyPredicate
            );
            $descriptor->setKeyDescriptor($keyDescriptor);
            if (!$keyDescriptor->isEmpty()) {
                $descriptor->setSingleResult(true); 
            }
        }
        if ($checkRights) {
            $resourceSetWrapper->checkResourceSetRightsForRead(
                $descriptor->isSingleResult()
            );
        }
        return $descriptor;
    }
private function _createFirstSegmentDescriptor ( $ segmentIdentifier , $ keyPredicate , $ checkRights ) { $ descriptor = new SegmentDescriptor ( ) ; $ descriptor -> setIdentifier ( $ segmentIdentifier ) ; if ( $ segmentIdentifier === ODataConstants :: URI_METADATA_SEGMENT ) { $ this -> _assertion ( is_null ( $ keyPredicate ) ) ; $ descriptor -> setTargetKind ( TargetKind :: METADATA ( ) ) ; return $ descriptor ; } if ( $ segmentIdentifier === ODataConstants :: URI_BATCH_SEGMENT ) { $ this -> _assertion ( is_null ( $ keyPredicate ) ) ; $ descriptor -> setTargetKind ( TargetKind :: BATCH ( ) ) ; return $ descriptor ; } if ( $ segmentIdentifier === ODataConstants :: URI_COUNT_SEGMENT ) { throw ODataException :: createBadRequestError ( Messages :: segmentParserSegmentNotAllowedOnRoot ( ODataConstants :: URI_COUNT_SEGMENT ) ) ; } if ( $ segmentIdentifier === ODataConstants :: URI_LINK_SEGMENT ) { throw ODataException :: createBadRequestError ( Messages :: segmentParserSegmentNotAllowedOnRoot ( ODataConstants :: URI_LINK_SEGMENT ) ) ; } $ resourceSetWrapper = $ this -> providerWrapper -> resolveResourceSet ( $ segmentIdentifier ) ; if ( $ resourceSetWrapper === null ) { throw ODataException :: createResourceNotFoundError ( $ segmentIdentifier ) ; } $ descriptor -> setTargetResourceSetWrapper ( $ resourceSetWrapper ) ; $ descriptor -> setTargetResourceType ( $ resourceSetWrapper -> getResourceType ( ) ) ; $ descriptor -> setTargetSource ( TargetSource :: ENTITY_SET ) ; $ descriptor -> setTargetKind ( TargetKind :: RESOURCE ( ) ) ; if ( $ keyPredicate !== null ) { $ keyDescriptor = $ this -> _createKeyDescriptor ( $ segmentIdentifier . '(' . $ keyPredicate . ')' , $ resourceSetWrapper -> getResourceType ( ) , $ keyPredicate ) ; $ descriptor -> setKeyDescriptor ( $ keyDescriptor ) ; if ( ! $ keyDescriptor -> isEmpty ( ) ) { $ descriptor -> setSingleResult ( true ) ; } } if ( $ checkRights ) { $ resourceSetWrapper -> checkResourceSetRightsForRead ( $ descriptor -> isSingleResult ( ) ) ; } return $ descriptor ; }
Create SegmentDescriptor for the first segment
Create SegmentDescriptor for the first segment