/** * Execute the client submitted request against the data source. */ public function execute() { $segments = $this->request->getSegments(); foreach ($segments as $segment) { $requestTargetKind = $segment->getTargetKind(); if ($segment->getTargetSource() == TargetSource::ENTITY_SET) { $this->handleSegmentTargetsToResourceSet($segment); } else { if ($requestTargetKind == TargetKind::RESOURCE()) { if (is_null($segment->getPrevious()->getResult())) { throw ODataException::createResourceNotFoundError($segment->getPrevious()->getIdentifier()); } $this->_handleSegmentTargetsToRelatedResource($segment); } else { if ($requestTargetKind == TargetKind::LINK()) { $segment->setResult($segment->getPrevious()->getResult()); } else { if ($segment->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { // we are done, $count will the last segment and // taken care by _applyQueryOptions method $segment->setResult($this->request->getCountValue()); break; } else { if ($requestTargetKind == TargetKind::MEDIA_RESOURCE()) { if (is_null($segment->getPrevious()->getResult())) { throw ODataException::createResourceNotFoundError($segment->getPrevious()->getIdentifier()); } // For MLE and Named Stream the result of last segment // should be that of previous segment, this is required // while retrieving content type or stream from IDSSP $segment->setResult($segment->getPrevious()->getResult()); // we are done, as named stream property or $value on // media resource will be the last segment break; } $value = $segment->getPrevious()->getResult(); while (!is_null($segment)) { //TODO: what exactly is this doing here? Once a null's found it seems everything will be null if (!is_null($value)) { $value = null; } else { try { //see #88 $property = new \ReflectionProperty($value, $segment->getIdentifier()); $value = $property->getValue($value); } catch (\ReflectionException $reflectionException) { //throw ODataException::createInternalServerError(Messages::orderByParserFailedToAccessOrInitializeProperty($resourceProperty->getName(), $resourceType->getName())); } } $segment->setResult($value); $segment = $segment->getNext(); if (!is_null($segment) && $segment->getIdentifier() == ODataConstants::URI_VALUE_SEGMENT) { $segment->setResult($value); $segment = $segment->getNext(); } } break; } } } } if (is_null($segment->getNext()) || $segment->getNext()->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { $this->applyQueryOptions($segment); } } // 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(); }