@@ -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 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function __construct(JsonLightMetadataLevel $metadataLevel, $absoluteServiceUri) |
| 47 | 47 | { |
| 48 | - if(strlen($absoluteServiceUri) == 0) |
|
| 48 | + if (strlen($absoluteServiceUri) == 0) |
|
| 49 | 49 | { |
| 50 | 50 | throw new \Exception("absoluteServiceUri must not be empty or null"); |
| 51 | 51 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function canHandle(Version $responseVersion, $contentType) |
| 69 | 69 | { |
| 70 | - if($responseVersion != Version::v3()){ |
|
| 70 | + if ($responseVersion != Version::v3()) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return JsonLightODataWriter |
| 88 | 88 | */ |
| 89 | - public function write($model){ |
|
| 89 | + public function write($model) { |
|
| 90 | 90 | $this->_writer->startObjectScope(); |
| 91 | 91 | |
| 92 | 92 | if ($model instanceof ODataURL) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $this->writeTopLevelMeta("urlCollection"); |
| 97 | 97 | $this->writeURLCollection($model); |
| 98 | 98 | } elseif ($model instanceof ODataPropertyContent) { |
| 99 | - $this->writeTopLevelMeta( $model->properties[0]->typeName ); |
|
| 99 | + $this->writeTopLevelMeta($model->properties[0]->typeName); |
|
| 100 | 100 | $this->writeTopLevelProperty($model->properties[0]); |
| 101 | 101 | } elseif ($model instanceof ODataFeed) { |
| 102 | 102 | $this->writeTopLevelMeta($model->title); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $this->writeFeed($model); |
| 109 | 109 | $this->_writer->endScope(); |
| 110 | 110 | }elseif ($model instanceof ODataEntry) { |
| 111 | - $this->writeTopLevelMeta($model->resourceSetName . "/@Element"); |
|
| 111 | + $this->writeTopLevelMeta($model->resourceSetName."/@Element"); |
|
| 112 | 112 | $this->writeEntry($model); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -150,34 +150,34 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | protected function writeTopLevelMeta($fragment) |
| 152 | 152 | { |
| 153 | - if($this->metadataLevel == JsonLightMetadataLevel::NONE()) |
|
| 153 | + if ($this->metadataLevel == JsonLightMetadataLevel::NONE()) |
|
| 154 | 154 | { |
| 155 | 155 | return; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | $this->_writer |
| 159 | 159 | ->writeName(ODataConstants::JSON_LIGHT_METADATA_STRING) |
| 160 | - ->writeValue($this->baseUri . '/' . ODataConstants::URI_METADATA_SEGMENT . '#' . $fragment); |
|
| 160 | + ->writeValue($this->baseUri.'/'.ODataConstants::URI_METADATA_SEGMENT.'#'.$fragment); |
|
| 161 | 161 | |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | |
| 165 | 165 | protected function writePropertyMeta(ODataProperty $property) |
| 166 | 166 | { |
| 167 | - if($this->metadataLevel != JsonLightMetadataLevel::FULL()) |
|
| 167 | + if ($this->metadataLevel != JsonLightMetadataLevel::FULL()) |
|
| 168 | 168 | { |
| 169 | 169 | //Only full meta level outputs this info |
| 170 | 170 | return $this; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - if(is_null($property->value)) |
|
| 173 | + if (is_null($property->value)) |
|
| 174 | 174 | { |
| 175 | 175 | //it appears full metadata doesn't output types for nulls... |
| 176 | 176 | return $this; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
| 180 | - switch($property->typeName) |
|
| 180 | + switch ($property->typeName) |
|
| 181 | 181 | { |
| 182 | 182 | //The type metadata is only included on certain types of properties |
| 183 | 183 | //Note this also excludes Complex types |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | case "Edm.Decimal": |
| 186 | 186 | case "Edm.DateTime": |
| 187 | 187 | $this->_writer |
| 188 | - ->writeName($property->name . ODataConstants::JSON_LIGHT_METADATA_PROPERTY_TYPE_SUFFIX_STRING) |
|
| 188 | + ->writeName($property->name.ODataConstants::JSON_LIGHT_METADATA_PROPERTY_TYPE_SUFFIX_STRING) |
|
| 189 | 189 | ->writeValue($property->typeName); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return JsonLightODataWriter |
| 201 | 201 | */ |
| 202 | - protected function writeEntryMetadata(ODataEntry $entry){ |
|
| 202 | + protected function writeEntryMetadata(ODataEntry $entry) { |
|
| 203 | 203 | |
| 204 | - if($this->metadataLevel != JsonLightMetadataLevel::FULL()) |
|
| 204 | + if ($this->metadataLevel != JsonLightMetadataLevel::FULL()) |
|
| 205 | 205 | { |
| 206 | 206 | //Only full meta level outputs this info |
| 207 | 207 | return $this; |
@@ -227,22 +227,22 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @return JsonLightODataWriter |
| 229 | 229 | */ |
| 230 | - protected function writeLink(ODataLink $link){ |
|
| 230 | + protected function writeLink(ODataLink $link) { |
|
| 231 | 231 | |
| 232 | - if($this->metadataLevel == JsonLightMetadataLevel::FULL()) |
|
| 232 | + if ($this->metadataLevel == JsonLightMetadataLevel::FULL()) |
|
| 233 | 233 | { |
| 234 | 234 | //Interestingly the fullmetadata outputs this metadata..even if the thing is expanded |
| 235 | 235 | $this->_writer |
| 236 | - ->writeName($link->title . ODataConstants::JSON_LIGHT_METADATA_LINK_NAVIGATION_SUFFIX_STRING) |
|
| 237 | - ->writeValue($link->url);; |
|
| 236 | + ->writeName($link->title.ODataConstants::JSON_LIGHT_METADATA_LINK_NAVIGATION_SUFFIX_STRING) |
|
| 237 | + ->writeValue($link->url); ; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
| 241 | - if($link->isExpanded) |
|
| 241 | + if ($link->isExpanded) |
|
| 242 | 242 | { |
| 243 | 243 | $this->_writer->writeName($link->title); |
| 244 | 244 | |
| 245 | - if(is_null($link->expandedResult)) { |
|
| 245 | + if (is_null($link->expandedResult)) { |
|
| 246 | 246 | $this->_writer->writeValue("null"); |
| 247 | 247 | } else { |
| 248 | 248 | $this->writeExpandedLink($link); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | protected function writeComplexPropertyMeta(ODataProperty $property) |
| 315 | 315 | { |
| 316 | - if($this->metadataLevel == JsonLightMetadataLevel::FULL()){ |
|
| 316 | + if ($this->metadataLevel == JsonLightMetadataLevel::FULL()) { |
|
| 317 | 317 | $this->_writer |
| 318 | 318 | ->writeName(ODataConstants::JSON_LIGHT_METADATA_TYPE_STRING) |
| 319 | 319 | ->writeValue($property->typeName); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
| 357 | - $this->_writer->endScope(); // ] |
|
| 357 | + $this->_writer->endScope(); // ] |
|
| 358 | 358 | return $this; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function canHandle(Version $responseVersion, $contentType) |
| 55 | 55 | { |
| 56 | - if($responseVersion != Version::v1()){ |
|
| 56 | + if ($responseVersion != Version::v1()) { |
|
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return JsonODataV1Writer |
| 71 | 71 | */ |
| 72 | - public function write($model){ |
|
| 72 | + public function write($model) { |
|
| 73 | 73 | // { "d" : |
| 74 | 74 | $this->_writer |
| 75 | 75 | ->startObjectScope() |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | $this->_writer->writeName($link->title); |
| 275 | 275 | |
| 276 | 276 | if ($link->isExpanded) { |
| 277 | - if(is_null($link->expandedResult)){ |
|
| 277 | + if (is_null($link->expandedResult)) { |
|
| 278 | 278 | $this->_writer->writeValue("null"); |
| 279 | 279 | } |
| 280 | - else{ |
|
| 280 | + else { |
|
| 281 | 281 | $this->writeExpandedLink($link); |
| 282 | 282 | } |
| 283 | 283 | } else { |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @param ProvidersWrapper $providers |
| 478 | 478 | * @return IODataWriter |
| 479 | 479 | */ |
| 480 | - public function writeServiceDocument(ProvidersWrapper $providers){ |
|
| 480 | + public function writeServiceDocument(ProvidersWrapper $providers) { |
|
| 481 | 481 | $writer = $this->_writer; |
| 482 | 482 | $writer |
| 483 | 483 | ->startObjectScope() // { |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | $parts = explode(";", $contentType); |
| 51 | 51 | |
| 52 | 52 | //special case, in v3 verbose is the v2 writer |
| 53 | - if($responseVersion == Version::v3()){ |
|
| 53 | + if ($responseVersion == Version::v3()) { |
|
| 54 | 54 | return in_array(MimeTypes::MIME_APPLICATION_JSON, $parts) && in_array('odata=verbose', $parts); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if($responseVersion != Version::v2()){ |
|
| 57 | + if ($responseVersion != Version::v2()) { |
|
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @return JsonODataV1Writer |
| 72 | 72 | */ |
| 73 | - public function write($model){ |
|
| 73 | + public function write($model) { |
|
| 74 | 74 | // { "d" : |
| 75 | 75 | $this->_writer |
| 76 | 76 | ->startObjectScope() |
@@ -211,7 +211,7 @@ |
||
| 211 | 211 | // Escape ( " \ / \n \r \t \b \f) characters with a backslash. |
| 212 | 212 | $search = array('\\', "\n", "\t", "\r", "\b", "\f", '"'); |
| 213 | 213 | $replace = array('\\\\', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'); |
| 214 | - $processedString = str_replace($search, $replace, $string); |
|
| 214 | + $processedString = str_replace($search, $replace, $string); |
|
| 215 | 215 | // Escape some ASCII characters(0x08, 0x0c) |
| 216 | 216 | $processedString = str_replace(array(chr(0x08), chr(0x0C)), array('\b', '\f'), $processedString); |
| 217 | 217 | return $processedString; |
@@ -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; |
@@ -216,7 +216,7 @@ |
||
| 216 | 216 | * |
| 217 | 217 | * @return void |
| 218 | 218 | */ |
| 219 | - public function getDataServiceAndEdmSchemaVersions(Version &$dsVersion, &$edmSchemaVersion) |
|
| 219 | + public function getDataServiceAndEdmSchemaVersions(Version & $dsVersion, &$edmSchemaVersion) |
|
| 220 | 220 | { |
| 221 | 221 | if ($this->_metadataResourceTypeSet->hasNamedStreams()) { |
| 222 | 222 | $dsVersion->raiseVersion(3, 0); |
@@ -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; |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | private function _writeNavigationProperty(ResourceType $resourceType, $associationTypesInResourceTypeNamespace, ResourceProperty $navigationProperty) |
| 368 | 368 | { |
| 369 | - $associationTypeLookupName = $resourceType->getName() . '_' . $navigationProperty->getName(); |
|
| 369 | + $associationTypeLookupName = $resourceType->getName().'_'.$navigationProperty->getName(); |
|
| 370 | 370 | if (!array_key_exists($associationTypeLookupName, $associationTypesInResourceTypeNamespace)) { |
| 371 | 371 | throw new InvalidOperationException(Messages::metadataWriterNoResourceAssociationSetForNavigationProperty($navigationProperty->getName(), $resourceType->getName())); |
| 372 | 372 | } |
@@ -503,8 +503,8 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | private function _writeAssocationSetEnds(ResourceAssociationSet $associationSet) |
| 505 | 505 | { |
| 506 | - $associationTypeEnd1 = $associationSet->resourceAssociationType->getResourceAssociationTypeEnd($associationSet->getEnd1()->getResourceType(), $associationSet->getEnd1()->getResourceProperty()); |
|
| 507 | - $associationTypeEnd2 = $associationSet->resourceAssociationType->getResourceAssociationTypeEnd($associationSet->getEnd2()->getResourceType(), $associationSet->getEnd2()->getResourceProperty()); |
|
| 506 | + $associationTypeEnd1 = $associationSet->resourceAssociationType->getResourceAssociationTypeEnd($associationSet->getEnd1()->getResourceType(), $associationSet->getEnd1()->getResourceProperty()); |
|
| 507 | + $associationTypeEnd2 = $associationSet->resourceAssociationType->getResourceAssociationTypeEnd($associationSet->getEnd2()->getResourceType(), $associationSet->getEnd2()->getResourceProperty()); |
|
| 508 | 508 | $this->_xmlWriter->startElement(ODataConstants::END); |
| 509 | 509 | $this->_xmlWriter->writeAttribute(ODataConstants::ROLE, $associationTypeEnd1->getName()); |
| 510 | 510 | $this->_xmlWriter->writeAttribute(ODataConstants::ENTITY_SET, $associationSet->getEnd1()->getResourceSet()->getName()); |