|
@@ 276-342 (lines=67) @@
|
| 273 |
|
|
| 274 |
|
$segments = $request->getSegments(); |
| 275 |
|
|
| 276 |
|
foreach ($segments as $segment) { |
| 277 |
|
|
| 278 |
|
$requestTargetKind = $segment->getTargetKind(); |
| 279 |
|
|
| 280 |
|
if ($segment->getTargetSource() == TargetSource::ENTITY_SET) { |
| 281 |
|
$this->handleSegmentTargetsToResourceSet($segment); |
| 282 |
|
} else if ($requestTargetKind == TargetKind::RESOURCE()) { |
| 283 |
|
if (is_null($segment->getPrevious()->getResult())) { |
| 284 |
|
throw ODataException::createResourceNotFoundError( |
| 285 |
|
$segment->getPrevious()->getIdentifier() |
| 286 |
|
); |
| 287 |
|
} |
| 288 |
|
$this->_handleSegmentTargetsToRelatedResource($segment); |
| 289 |
|
} else if ($requestTargetKind == TargetKind::LINK()) { |
| 290 |
|
$segment->setResult($segment->getPrevious()->getResult()); |
| 291 |
|
} else if ($segment->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { |
| 292 |
|
// we are done, $count will the last segment and |
| 293 |
|
// taken care by _applyQueryOptions method |
| 294 |
|
$segment->setResult($this->request->getCountValue()); |
| 295 |
|
break; |
| 296 |
|
} else { |
| 297 |
|
if ($requestTargetKind == TargetKind::MEDIA_RESOURCE()) { |
| 298 |
|
if (is_null($segment->getPrevious()->getResult())) { |
| 299 |
|
throw ODataException::createResourceNotFoundError( |
| 300 |
|
$segment->getPrevious()->getIdentifier() |
| 301 |
|
); |
| 302 |
|
} |
| 303 |
|
// For MLE and Named Stream the result of last segment |
| 304 |
|
// should be that of previous segment, this is required |
| 305 |
|
// while retrieving content type or stream from IDSSP |
| 306 |
|
$segment->setResult($segment->getPrevious()->getResult()); |
| 307 |
|
// we are done, as named stream property or $value on |
| 308 |
|
// media resource will be the last segment |
| 309 |
|
break; |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
$value = $segment->getPrevious()->getResult(); |
| 313 |
|
while (!is_null($segment)) { |
| 314 |
|
//TODO: what exactly is this doing here? Once a null's found it seems everything will be null |
| 315 |
|
if (!is_null($value)) { |
| 316 |
|
$value = null; |
| 317 |
|
} else { |
| 318 |
|
try { |
| 319 |
|
//see #88 |
| 320 |
|
$property = new \ReflectionProperty($value, $segment->getIdentifier()); |
| 321 |
|
$value = $property->getValue($value); |
| 322 |
|
} catch (\ReflectionException $reflectionException) { |
| 323 |
|
//throw ODataException::createInternalServerError(Messages::orderByParserFailedToAccessOrInitializeProperty($resourceProperty->getName(), $resourceType->getName())); |
| 324 |
|
} |
| 325 |
|
} |
| 326 |
|
|
| 327 |
|
$segment->setResult($value); |
| 328 |
|
$segment = $segment->getNext(); |
| 329 |
|
if (!is_null($segment) && $segment->getIdentifier() == ODataConstants::URI_VALUE_SEGMENT) { |
| 330 |
|
$segment->setResult($value); |
| 331 |
|
$segment = $segment->getNext(); |
| 332 |
|
} |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
break; |
| 336 |
|
|
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
if (is_null($segment->getNext()) || $segment->getNext()->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { |
| 340 |
|
$this->applyQueryOptions($segment, $callback); |
| 341 |
|
} |
| 342 |
|
} |
| 343 |
|
|
| 344 |
|
// Apply $select and $expand options to result set, this function will be always applied |
| 345 |
|
// irrespective of return value of IDSQP2::canApplyQueryOptions which means library will |
|
@@ 383-449 (lines=67) @@
|
| 380 |
|
{ |
| 381 |
|
$segments = $this->request->getSegments(); |
| 382 |
|
|
| 383 |
|
foreach ($segments as $segment) { |
| 384 |
|
|
| 385 |
|
$requestTargetKind = $segment->getTargetKind(); |
| 386 |
|
|
| 387 |
|
if ($segment->getTargetSource() == TargetSource::ENTITY_SET) { |
| 388 |
|
$this->handleSegmentTargetsToResourceSet($segment); |
| 389 |
|
} else if ($requestTargetKind == TargetKind::RESOURCE()) { |
| 390 |
|
if (is_null($segment->getPrevious()->getResult())) { |
| 391 |
|
throw ODataException::createResourceNotFoundError( |
| 392 |
|
$segment->getPrevious()->getIdentifier() |
| 393 |
|
); |
| 394 |
|
} |
| 395 |
|
$this->_handleSegmentTargetsToRelatedResource($segment); |
| 396 |
|
} else if ($requestTargetKind == TargetKind::LINK()) { |
| 397 |
|
$segment->setResult($segment->getPrevious()->getResult()); |
| 398 |
|
} else if ($segment->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { |
| 399 |
|
// we are done, $count will the last segment and |
| 400 |
|
// taken care by _applyQueryOptions method |
| 401 |
|
$segment->setResult($this->request->getCountValue()); |
| 402 |
|
break; |
| 403 |
|
} else { |
| 404 |
|
if ($requestTargetKind == TargetKind::MEDIA_RESOURCE()) { |
| 405 |
|
if (is_null($segment->getPrevious()->getResult())) { |
| 406 |
|
throw ODataException::createResourceNotFoundError( |
| 407 |
|
$segment->getPrevious()->getIdentifier() |
| 408 |
|
); |
| 409 |
|
} |
| 410 |
|
// For MLE and Named Stream the result of last segment |
| 411 |
|
// should be that of previous segment, this is required |
| 412 |
|
// while retrieving content type or stream from IDSSP |
| 413 |
|
$segment->setResult($segment->getPrevious()->getResult()); |
| 414 |
|
// we are done, as named stream property or $value on |
| 415 |
|
// media resource will be the last segment |
| 416 |
|
break; |
| 417 |
|
} |
| 418 |
|
|
| 419 |
|
$value = $segment->getPrevious()->getResult(); |
| 420 |
|
while (!is_null($segment)) { |
| 421 |
|
//TODO: what exactly is this doing here? Once a null's found it seems everything will be null |
| 422 |
|
if (!is_null($value)) { |
| 423 |
|
$value = null; |
| 424 |
|
} else { |
| 425 |
|
try { |
| 426 |
|
//see #88 |
| 427 |
|
$property = new \ReflectionProperty($value, $segment->getIdentifier()); |
| 428 |
|
$value = $property->getValue($value); |
| 429 |
|
} catch (\ReflectionException $reflectionException) { |
| 430 |
|
//throw ODataException::createInternalServerError(Messages::orderByParserFailedToAccessOrInitializeProperty($resourceProperty->getName(), $resourceType->getName())); |
| 431 |
|
} |
| 432 |
|
} |
| 433 |
|
|
| 434 |
|
$segment->setResult($value); |
| 435 |
|
$segment = $segment->getNext(); |
| 436 |
|
if (!is_null($segment) && $segment->getIdentifier() == ODataConstants::URI_VALUE_SEGMENT) { |
| 437 |
|
$segment->setResult($value); |
| 438 |
|
$segment = $segment->getNext(); |
| 439 |
|
} |
| 440 |
|
} |
| 441 |
|
|
| 442 |
|
break; |
| 443 |
|
|
| 444 |
|
} |
| 445 |
|
|
| 446 |
|
if (is_null($segment->getNext()) || $segment->getNext()->getIdentifier() == ODataConstants::URI_COUNT_SEGMENT) { |
| 447 |
|
$this->applyQueryOptions($segment, $callback); |
| 448 |
|
} |
| 449 |
|
} |
| 450 |
|
|
| 451 |
|
// Apply $select and $expand options to result set, this function will be always applied |
| 452 |
|
// irrespective of return value of IDSQP2::canApplyQueryOptions which means library will |