@@ -20,23 +20,23 @@ |
||
| 20 | 20 | interface IODataWriter |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Determines if the given writer is capable of writing the response or not |
|
| 25 | - * @param Version $responseVersion the OData version of the response |
|
| 26 | - * @param string $contentType the Content Type of the response |
|
| 27 | - * @return boolean true if the writer can handle the response, false otherwise |
|
| 28 | - */ |
|
| 29 | - public function canHandle(Version $responseVersion, $contentType); |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Create OData object model from the request description and transform it to required content type form |
|
| 33 | - * |
|
| 34 | - * |
|
| 35 | - * @param ODataURL|ODataURLCollection|ODataPropertyContent|ODataFeed|ODataEntry $model Object of requested content. |
|
| 36 | - * |
|
| 37 | - * @return IODataWriter |
|
| 38 | - */ |
|
| 39 | - public function write($model); |
|
| 23 | + /** |
|
| 24 | + * Determines if the given writer is capable of writing the response or not |
|
| 25 | + * @param Version $responseVersion the OData version of the response |
|
| 26 | + * @param string $contentType the Content Type of the response |
|
| 27 | + * @return boolean true if the writer can handle the response, false otherwise |
|
| 28 | + */ |
|
| 29 | + public function canHandle(Version $responseVersion, $contentType); |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Create OData object model from the request description and transform it to required content type form |
|
| 33 | + * |
|
| 34 | + * |
|
| 35 | + * @param ODataURL|ODataURLCollection|ODataPropertyContent|ODataFeed|ODataEntry $model Object of requested content. |
|
| 36 | + * |
|
| 37 | + * @return IODataWriter |
|
| 38 | + */ |
|
| 39 | + public function write($model); |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -54,62 +54,62 @@ |
||
| 54 | 54 | { |
| 55 | 55 | $this->outputTabs(); |
| 56 | 56 | $this->_write($value); |
| 57 | - return $this; |
|
| 57 | + return $this; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Writes a new line character to the text stream |
|
| 62 | - * |
|
| 63 | - * @return IndentedTextWriter |
|
| 64 | - */ |
|
| 65 | - public function writeLine() |
|
| 66 | - { |
|
| 67 | - $this->_write("\n"); |
|
| 68 | - $this->tabsPending = true; |
|
| 69 | - return $this; |
|
| 70 | - } |
|
| 60 | + /** |
|
| 61 | + * Writes a new line character to the text stream |
|
| 62 | + * |
|
| 63 | + * @return IndentedTextWriter |
|
| 64 | + */ |
|
| 65 | + public function writeLine() |
|
| 66 | + { |
|
| 67 | + $this->_write("\n"); |
|
| 68 | + $this->tabsPending = true; |
|
| 69 | + return $this; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Writes the given text trimmed with no indentation |
|
| 74 | - * |
|
| 75 | - * @param string $value text to be written |
|
| 76 | - * |
|
| 77 | - * @return IndentedTextWriter |
|
| 78 | - */ |
|
| 79 | - public function writeTrimmed($value) |
|
| 80 | - { |
|
| 81 | - $this->_write(trim($value)); |
|
| 82 | - return $this; |
|
| 83 | - } |
|
| 72 | + /** |
|
| 73 | + * Writes the given text trimmed with no indentation |
|
| 74 | + * |
|
| 75 | + * @param string $value text to be written |
|
| 76 | + * |
|
| 77 | + * @return IndentedTextWriter |
|
| 78 | + */ |
|
| 79 | + public function writeTrimmed($value) |
|
| 80 | + { |
|
| 81 | + $this->_write(trim($value)); |
|
| 82 | + return $this; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Increases the current indent setting by 1 |
|
| 87 | - * @return IndentedTextWriter |
|
| 88 | - */ |
|
| 89 | - public function increaseIndent() |
|
| 90 | - { |
|
| 91 | - $this->indentLevel++; |
|
| 92 | - return $this; |
|
| 93 | - } |
|
| 85 | + /** |
|
| 86 | + * Increases the current indent setting by 1 |
|
| 87 | + * @return IndentedTextWriter |
|
| 88 | + */ |
|
| 89 | + public function increaseIndent() |
|
| 90 | + { |
|
| 91 | + $this->indentLevel++; |
|
| 92 | + return $this; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Decreases the current indent setting by 1, never going below 0 |
|
| 97 | - * @return IndentedTextWriter |
|
| 98 | - */ |
|
| 99 | - public function decreaseIndent() |
|
| 100 | - { |
|
| 101 | - if($this->indentLevel > 0) $this->indentLevel--; |
|
| 102 | - return $this; |
|
| 103 | - } |
|
| 95 | + /** |
|
| 96 | + * Decreases the current indent setting by 1, never going below 0 |
|
| 97 | + * @return IndentedTextWriter |
|
| 98 | + */ |
|
| 99 | + public function decreaseIndent() |
|
| 100 | + { |
|
| 101 | + if($this->indentLevel > 0) $this->indentLevel--; |
|
| 102 | + return $this; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * @return string the current written text |
|
| 108 | - */ |
|
| 109 | - public function getResult() |
|
| 110 | - { |
|
| 111 | - return $this->result; |
|
| 112 | - } |
|
| 106 | + /** |
|
| 107 | + * @return string the current written text |
|
| 108 | + */ |
|
| 109 | + public function getResult() |
|
| 110 | + { |
|
| 111 | + return $this->result; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * Writes the tabs depending on the indent level |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | */ |
| 99 | 99 | public function decreaseIndent() |
| 100 | 100 | { |
| 101 | - if($this->indentLevel > 0) $this->indentLevel--; |
|
| 101 | + if ($this->indentLevel > 0) $this->indentLevel--; |
|
| 102 | 102 | return $this; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -98,7 +98,9 @@ |
||
| 98 | 98 | */ |
| 99 | 99 | public function decreaseIndent() |
| 100 | 100 | { |
| 101 | - if($this->indentLevel > 0) $this->indentLevel--; |
|
| 101 | + if($this->indentLevel > 0) { |
|
| 102 | + $this->indentLevel--; |
|
| 103 | + } |
|
| 102 | 104 | return $this; |
| 103 | 105 | } |
| 104 | 106 | |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | * @method static \POData\Writers\Json\JsonLightMetadataLevel FULL() |
| 16 | 16 | */ |
| 17 | 17 | class JsonLightMetadataLevel extends Enum { |
| 18 | - //using these const because it makes them easy to use in writer canHandle..but maybe not such a good idea |
|
| 19 | - const NONE = "odata=nometadata"; |
|
| 18 | + //using these const because it makes them easy to use in writer canHandle..but maybe not such a good idea |
|
| 19 | + const NONE = "odata=nometadata"; |
|
| 20 | 20 | |
| 21 | - const MINIMAL = "odata=minimalmetadata"; |
|
| 21 | + const MINIMAL = "odata=minimalmetadata"; |
|
| 22 | 22 | |
| 23 | - const FULL = "odata=fullmetadata"; |
|
| 23 | + const FULL = "odata=fullmetadata"; |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | private function _getResourceAssociationSet(ResourceSetWrapper $resourceSet, ResourceType $resourceType, ResourceProperty $navigationProperty) |
| 254 | 254 | { |
| 255 | - $associationSetLookupKey = $resourceSet->getName() . '_' . $resourceType->getFullName() . '_' . $navigationProperty->getName(); |
|
| 255 | + $associationSetLookupKey = $resourceSet->getName().'_'.$resourceType->getFullName().'_'.$navigationProperty->getName(); |
|
| 256 | 256 | if (array_key_exists($associationSetLookupKey, $this->_resourceAssociationSets)) { |
| 257 | 257 | return $this->_resourceAssociationSets[$associationSetLookupKey]; |
| 258 | 258 | } |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | $reverseAssociationSetLookupKey = null; |
| 292 | 292 | if (!is_null($relatedEnd->getResourceProperty())) { |
| 293 | - $reverseAssociationSetLookupKey = $relatedEnd->getResourceSet()->getName() . '_' . $relatedEnd->getResourceProperty()->getResourceType()->getFullName() . '_' . $relatedEnd->getResourceProperty()->getName(); |
|
| 293 | + $reverseAssociationSetLookupKey = $relatedEnd->getResourceSet()->getName().'_'.$relatedEnd->getResourceProperty()->getResourceType()->getFullName().'_'.$relatedEnd->getResourceProperty()->getName(); |
|
| 294 | 294 | } else { |
| 295 | - $reverseAssociationSetLookupKey = $relatedEnd->getResourceSet()->getName() . '_Null_' . $resourceType->getFullName() . '_' . $navigationProperty->getName(); |
|
| 295 | + $reverseAssociationSetLookupKey = $relatedEnd->getResourceSet()->getName().'_Null_'.$resourceType->getFullName().'_'.$navigationProperty->getName(); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | if (array_key_exists($reverseAssociationSetLookupKey, $this->_resourceAssociationSets)) { |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | { |
| 333 | 333 | $resourceTypeNamespace = $this->getResourceTypeNamespace($resourceType); |
| 334 | 334 | $resourceAssociationTypesInNamespace = &$this->getResourceAssociationTypesForNamespace($resourceTypeNamespace); |
| 335 | - $associationTypeLookupKey = $resourceType->getName() . '_' . $navigationProperty->getName(); |
|
| 335 | + $associationTypeLookupKey = $resourceType->getName().'_'.$navigationProperty->getName(); |
|
| 336 | 336 | if (array_key_exists($associationTypeLookupKey, $resourceAssociationTypesInNamespace)) { |
| 337 | 337 | return $resourceAssociationTypesInNamespace[$associationTypeLookupKey]; |
| 338 | 338 | } |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | $associationTypeEnd1Name = $associationTypeEnd2Name = null; |
| 343 | 343 | $isBiDirectional = $resourceAssociationSet->isBidirectional(); |
| 344 | 344 | if ($isBiDirectional) { |
| 345 | - $associationTypeEnd1Name = $resourceAssociationSet->getEnd1()->getResourceType()->getName() . '_' . $resourceAssociationSet->getEnd1()->getResourceProperty()->getName(); |
|
| 346 | - $associationTypeEnd2Name = $resourceAssociationSet->getEnd2()->getResourceType()->getName() . '_' . $resourceAssociationSet->getEnd2()->getResourceProperty()->getName(); |
|
| 345 | + $associationTypeEnd1Name = $resourceAssociationSet->getEnd1()->getResourceType()->getName().'_'.$resourceAssociationSet->getEnd1()->getResourceProperty()->getName(); |
|
| 346 | + $associationTypeEnd2Name = $resourceAssociationSet->getEnd2()->getResourceType()->getName().'_'.$resourceAssociationSet->getEnd2()->getResourceProperty()->getName(); |
|
| 347 | 347 | } else { |
| 348 | 348 | if (!is_null($resourceAssociationSet->getEnd1()->getResourceProperty())) { |
| 349 | 349 | $associationTypeEnd1Name = $resourceAssociationSet->getEnd1()->getResourceType()->getName(); |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $resourceAssociationTypesInNamespace[$associationTypeLookupKey] = $resourceAssociationType; |
| 379 | 379 | if ($isBiDirectional) { |
| 380 | 380 | $relatedAssociationSetEnd = $resourceAssociationSet->getRelatedResourceAssociationSetEnd($resourceSet->getResourceSet(), $resourceType, $navigationProperty); |
| 381 | - $relatedEndLookupKey = $relatedAssociationSetEnd->getResourceType()->getName() . '_' . $relatedAssociationSetEnd->getResourceProperty()->getName(); |
|
| 381 | + $relatedEndLookupKey = $relatedAssociationSetEnd->getResourceType()->getName().'_'.$relatedAssociationSetEnd->getResourceProperty()->getName(); |
|
| 382 | 382 | $resourceAssociationTypesInNamespace[$relatedEndLookupKey] = $resourceAssociationType; |
| 383 | 383 | } |
| 384 | 384 | |
@@ -399,14 +399,13 @@ discard block |
||
| 399 | 399 | private function _getAssociationTypeName(ResourceAssociationSet $resourceAssociationSet) |
| 400 | 400 | { |
| 401 | 401 | $end1 = !is_null($resourceAssociationSet->getEnd1()->getResourceProperty()) ? |
| 402 | - $resourceAssociationSet->getEnd1() : |
|
| 403 | - $resourceAssociationSet->getEnd2(); |
|
| 402 | + $resourceAssociationSet->getEnd1() : $resourceAssociationSet->getEnd2(); |
|
| 404 | 403 | $end2 = $resourceAssociationSet->getRelatedResourceAssociationSetEnd($end1->getResourceSet(), $end1->getResourceType(), $end1->getResourceProperty()); |
| 405 | 404 | //e.g. Customer_Orders (w.r.t Northwind DB) |
| 406 | - $associationTypeName = $end1->getResourceType()->getName() . '_' . $end1->getResourceProperty()->getName(); |
|
| 405 | + $associationTypeName = $end1->getResourceType()->getName().'_'.$end1->getResourceProperty()->getName(); |
|
| 407 | 406 | if (!is_null($end2->getResourceProperty())) { |
| 408 | 407 | //Customer_Orders_Order_Customer |
| 409 | - $associationTypeName .= '_' . $end2->getResourceType()->getName() . '_' . $end2->getResourceProperty()->getName(); |
|
| 408 | + $associationTypeName .= '_'.$end2->getResourceType()->getName().'_'.$end2->getResourceProperty()->getName(); |
|
| 410 | 409 | } |
| 411 | 410 | |
| 412 | 411 | return $associationTypeName; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $resourceType = $resourceProperty->getResourceType(); |
| 180 | 180 | $resourceTypeNamespace = $this->getResourceTypeNamespace($resourceType); |
| 181 | 181 | $resourceTypesInNamespace = $this->getResourceTypesForNamespace($resourceTypeNamespace); |
| 182 | - if (!array_key_exists($resourceTypeNamespace . '.' . $resourceType->getName(), $resourceTypesInNamespace)) { |
|
| 182 | + if (!array_key_exists($resourceTypeNamespace.'.'.$resourceType->getName(), $resourceTypesInNamespace)) { |
|
| 183 | 183 | continue; |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | { |
| 243 | 243 | $resourceTypeNamespace = $this->getResourceTypeNamespace($resourceType); |
| 244 | 244 | $resourceTypesInNamespace = &$this->getResourceTypesForNamespace($resourceTypeNamespace); |
| 245 | - $resourceNameWithNamespace = $resourceTypeNamespace . '.' . $resourceType->getName(); |
|
| 245 | + $resourceNameWithNamespace = $resourceTypeNamespace.'.'.$resourceType->getName(); |
|
| 246 | 246 | if (!array_key_exists($resourceNameWithNamespace, $resourceTypesInNamespace)) { |
| 247 | 247 | if ($resourceType->isMediaLinkEntry()) { |
| 248 | 248 | $this->_hasVisibleMediaLinkEntry = true; |
@@ -12,35 +12,35 @@ |
||
| 12 | 12 | class ODataWriterRegistry |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** @var IODataWriter[] */ |
|
| 16 | - private $writers = array(); |
|
| 17 | - |
|
| 18 | - |
|
| 19 | - public function register(IODataWriter $writer) |
|
| 20 | - { |
|
| 21 | - $this->writers[] = $writer; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public function reset() |
|
| 25 | - { |
|
| 26 | - $this->writers = array(); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @param Version $responseVersion |
|
| 31 | - * @param $contentType |
|
| 32 | - * |
|
| 33 | - * @return IODataWriter|null the writer that can handle the give criteria, or null |
|
| 34 | - */ |
|
| 35 | - public function getWriter(Version $responseVersion, $contentType){ |
|
| 36 | - |
|
| 37 | - foreach($this->writers as $writer) |
|
| 38 | - { |
|
| 39 | - if($writer->canHandle($responseVersion, $contentType)) return $writer; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - return null; |
|
| 43 | - } |
|
| 15 | + /** @var IODataWriter[] */ |
|
| 16 | + private $writers = array(); |
|
| 17 | + |
|
| 18 | + |
|
| 19 | + public function register(IODataWriter $writer) |
|
| 20 | + { |
|
| 21 | + $this->writers[] = $writer; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public function reset() |
|
| 25 | + { |
|
| 26 | + $this->writers = array(); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @param Version $responseVersion |
|
| 31 | + * @param $contentType |
|
| 32 | + * |
|
| 33 | + * @return IODataWriter|null the writer that can handle the give criteria, or null |
|
| 34 | + */ |
|
| 35 | + public function getWriter(Version $responseVersion, $contentType){ |
|
| 36 | + |
|
| 37 | + foreach($this->writers as $writer) |
|
| 38 | + { |
|
| 39 | + if($writer->canHandle($responseVersion, $contentType)) return $writer; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + return null; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | * |
| 33 | 33 | * @return IODataWriter|null the writer that can handle the give criteria, or null |
| 34 | 34 | */ |
| 35 | - public function getWriter(Version $responseVersion, $contentType){ |
|
| 35 | + public function getWriter(Version $responseVersion, $contentType) { |
|
| 36 | 36 | |
| 37 | - foreach($this->writers as $writer) |
|
| 37 | + foreach ($this->writers as $writer) |
|
| 38 | 38 | { |
| 39 | - if($writer->canHandle($responseVersion, $contentType)) return $writer; |
|
| 39 | + if ($writer->canHandle($responseVersion, $contentType)) return $writer; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return null; |
@@ -36,7 +36,9 @@ |
||
| 36 | 36 | |
| 37 | 37 | foreach($this->writers as $writer) |
| 38 | 38 | { |
| 39 | - if($writer->canHandle($responseVersion, $contentType)) return $writer; |
|
| 39 | + if($writer->canHandle($responseVersion, $contentType)) { |
|
| 40 | + return $writer; |
|
| 41 | + } |
|
| 40 | 42 | } |
| 41 | 43 | |
| 42 | 44 | return null; |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | */ |
| 31 | 31 | public static function write( |
| 32 | - IService $service, |
|
| 32 | + IService $service, |
|
| 33 | 33 | RequestDescription $request, |
| 34 | 34 | $entityModel, |
| 35 | 35 | $responseContentType |
| 36 | 36 | ) { |
| 37 | 37 | $responseBody = null; |
| 38 | 38 | $dataServiceVersion = $request->getResponseVersion(); |
| 39 | - $targetKind = $request->getTargetKind(); |
|
| 39 | + $targetKind = $request->getTargetKind(); |
|
| 40 | 40 | |
| 41 | 41 | if ($targetKind == TargetKind::METADATA()) { |
| 42 | 42 | // /$metadata |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | $responseBody = $writer->writeMetadata(); |
| 45 | 45 | $dataServiceVersion = $writer->getDataServiceVersion(); |
| 46 | 46 | } else if ($targetKind == TargetKind::PRIMITIVE_VALUE() && $responseContentType != MimeTypes::MIME_APPLICATION_OCTETSTREAM) { |
| 47 | - //This second part is to exclude binary properties |
|
| 47 | + //This second part is to exclude binary properties |
|
| 48 | 48 | // /Customer('ALFKI')/CompanyName/$value |
| 49 | 49 | // /Customers/$count |
| 50 | 50 | $responseBody = utf8_encode($request->getTargetResult()); |
| 51 | 51 | } else if ($responseContentType == MimeTypes::MIME_APPLICATION_OCTETSTREAM || $targetKind == TargetKind::MEDIA_RESOURCE()) { |
| 52 | 52 | // Binary property or media resource |
| 53 | 53 | if ($request->getTargetKind() == TargetKind::MEDIA_RESOURCE()) { |
| 54 | - $result = $request->getTargetResult(); |
|
| 55 | - $streamInfo = $request->getResourceStreamInfo(); |
|
| 56 | - $provider = $service->getStreamProviderWrapper(); |
|
| 54 | + $result = $request->getTargetResult(); |
|
| 55 | + $streamInfo = $request->getResourceStreamInfo(); |
|
| 56 | + $provider = $service->getStreamProviderWrapper(); |
|
| 57 | 57 | $eTag = $provider->getStreamETag( $result, $streamInfo ); |
| 58 | 58 | $service->getHost()->setResponseETag($eTag); |
| 59 | 59 | $responseBody = $provider->getReadStream( $result, $streamInfo ); |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | } else { |
| 68 | 68 | $writer = $service->getODataWriterRegistry()->getWriter($request->getResponseVersion(), $responseContentType); |
| 69 | - //TODO: move ot Messages |
|
| 70 | - if(is_null($writer)) throw new \Exception("no writer can handle the request"); |
|
| 69 | + //TODO: move ot Messages |
|
| 70 | + if(is_null($writer)) throw new \Exception("no writer can handle the request"); |
|
| 71 | 71 | |
| 72 | 72 | if (is_null($entityModel)) { //TODO: this seems like a weird way to know that the request is for a service document..i'd think we know this some other way |
| 73 | 73 | $responseBody = $writer->writeServiceDocument($service->getProvidersWrapper())->getOutput(); |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | // Binary property or media resource |
| 53 | 53 | if ($request->getTargetKind() == TargetKind::MEDIA_RESOURCE()) { |
| 54 | 54 | $result = $request->getTargetResult(); |
| 55 | - $streamInfo = $request->getResourceStreamInfo(); |
|
| 55 | + $streamInfo = $request->getResourceStreamInfo(); |
|
| 56 | 56 | $provider = $service->getStreamProviderWrapper(); |
| 57 | - $eTag = $provider->getStreamETag( $result, $streamInfo ); |
|
| 57 | + $eTag = $provider->getStreamETag($result, $streamInfo); |
|
| 58 | 58 | $service->getHost()->setResponseETag($eTag); |
| 59 | - $responseBody = $provider->getReadStream( $result, $streamInfo ); |
|
| 59 | + $responseBody = $provider->getReadStream($result, $streamInfo); |
|
| 60 | 60 | } else { |
| 61 | 61 | $responseBody = $request->getTargetResult(); |
| 62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } else { |
| 68 | 68 | $writer = $service->getODataWriterRegistry()->getWriter($request->getResponseVersion(), $responseContentType); |
| 69 | 69 | //TODO: move ot Messages |
| 70 | - if(is_null($writer)) throw new \Exception("no writer can handle the request"); |
|
| 70 | + if (is_null($writer)) throw new \Exception("no writer can handle the request"); |
|
| 71 | 71 | |
| 72 | 72 | if (is_null($entityModel)) { //TODO: this seems like a weird way to know that the request is for a service document..i'd think we know this some other way |
| 73 | 73 | $responseBody = $writer->writeServiceDocument($service->getProvidersWrapper())->getOutput(); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $service->getHost()->setResponseStatusCode(HttpStatus::CODE_OK); |
| 81 | 81 | $service->getHost()->setResponseContentType($responseContentType); |
| 82 | - $service->getHost()->setResponseVersion($dataServiceVersion->toString() .';'); |
|
| 82 | + $service->getHost()->setResponseVersion($dataServiceVersion->toString().';'); |
|
| 83 | 83 | $service->getHost()->setResponseCacheControl(ODataConstants::HTTPRESPONSE_HEADER_CACHECONTROL_NOCACHE); |
| 84 | 84 | $service->getHost()->getOperationContext()->outgoingResponse()->setStream($responseBody); |
| 85 | 85 | } |
@@ -67,12 +67,13 @@ |
||
| 67 | 67 | } else { |
| 68 | 68 | $writer = $service->getODataWriterRegistry()->getWriter($request->getResponseVersion(), $responseContentType); |
| 69 | 69 | //TODO: move ot Messages |
| 70 | - if(is_null($writer)) throw new \Exception("no writer can handle the request"); |
|
| 70 | + if(is_null($writer)) { |
|
| 71 | + throw new \Exception("no writer can handle the request"); |
|
| 72 | + } |
|
| 71 | 73 | |
| 72 | 74 | if (is_null($entityModel)) { //TODO: this seems like a weird way to know that the request is for a service document..i'd think we know this some other way |
| 73 | 75 | $responseBody = $writer->writeServiceDocument($service->getProvidersWrapper())->getOutput(); |
| 74 | - } |
|
| 75 | - else { |
|
| 76 | + } else { |
|
| 76 | 77 | $responseBody = $writer->write($entityModel)->getOutput(); |
| 77 | 78 | } |
| 78 | 79 | } |