/** * Execute the client submitted request aganist the data source. * * @return void */ public function execute() { $segmentDescriptors =& $this->_requestDescription->getSegmentDescriptors(); foreach ($segmentDescriptors as $segmentDescriptor) { $requestTargetKind = $segmentDescriptor->getTargetKind(); if ($segmentDescriptor->getTargetSource() == RequestTargetSource::ENTITY_SET) { $this->_handleSegmentTargetsToResourceSet($segmentDescriptor); } else { if ($requestTargetKind == RequestTargetKind::RESOURCE) { if (is_null($segmentDescriptor->getPrevious()->getResult())) { ODataException::createResourceNotFoundError($segmentDescriptor->getPrevious()->getIdentifier()); } $this->_handleSegmentTargetsToRelatedResource($segmentDescriptor); } else { if ($requestTargetKind == RequestTargetKind::LINK) { $segmentDescriptor->setResult($segmentDescriptor->getPrevious()->getResult()); } else { if ($segmentDescriptor->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { // we are done, $count will the last segment and // taken care by _applyQueryOptions method $segmentDescriptor->setResult($this->_requestDescription->getCountValue()); break; } else { if ($requestTargetKind == RequestTargetKind::MEDIA_RESOURCE) { if (is_null($segmentDescriptor->getPrevious()->getResult())) { ODataException::createResourceNotFoundError($segmentDescriptor->getPrevious()->getIdentifier()); } // For MLE and Named Stream the result of last segment // should be that of previous segment, this is required // while retriving content type or stream from IDSSP $segmentDescriptor->setResult($segmentDescriptor->getPrevious()->getResult()); // we are done, as named stream property or $value on // media resource will be the last segment break; } else { $value = $segmentDescriptor->getPrevious()->getResult(); while (!is_null($segmentDescriptor)) { if (is_null($value)) { $value = null; } else { try { $property = new \ReflectionProperty($value, $segmentDescriptor->getIdentifier()); $value = $property->getValue($value); } catch (\ReflectionException $reflectionException) { //throw ODataException::createInternalServerError(Messages::orderByParserFailedToAccessOrInitializeProperty($resourceProperty->getName(), $resourceType->getName())); } } $segmentDescriptor->setResult($value); $segmentDescriptor = $segmentDescriptor->getNext(); if (!is_null($segmentDescriptor) && $segmentDescriptor->getIdentifier() == ODataConstants::URI_VALUE_SEGMENT) { $segmentDescriptor->setResult($value); $segmentDescriptor = $segmentDescriptor->getNext(); } } //done, exit from outer loop as inner while complete traversal. break; } } } } } if (is_null($segmentDescriptor->getNext()) || $segmentDescriptor->getNext()->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { $this->_applyQueryOptions($segmentDescriptor); } } // Apply $select and $expand options to result set, this function will be always applied // irrespective of return value of IDSQP2::canApplyQueryOptions which means library will // not delegate $expand/$select operation to IDSQP2 implementation $this->_handleExpansion(); }