|
@@ 246-260 (lines=15) @@
|
| 243 |
|
/** |
| 244 |
|
* For queries like http://localhost/NorthWind.svc/Customers(‘ALFKI’)/Orders(10643). |
| 245 |
|
*/ |
| 246 |
|
public function getResourceFromRelatedResourceSet( |
| 247 |
|
ResourceSet $sourceResourceSet, |
| 248 |
|
$sourceEntityInstance, |
| 249 |
|
ResourceSet $targetResourceSet, |
| 250 |
|
ResourceProperty $targetProperty, |
| 251 |
|
KeyDescriptor $keyDescriptor |
| 252 |
|
) { |
| 253 |
|
$entityClassName = $sourceResourceSet->getResourceType()->getInstanceType()->name; |
| 254 |
|
$entityName = $this->getEntityName($entityClassName); |
| 255 |
|
$fieldName = $this->getTableName($entityName) . '_id'; |
| 256 |
|
|
| 257 |
|
return $this->getResource($targetResourceSet, $keyDescriptor, [ |
| 258 |
|
$fieldName => $sourceEntityInstance->id, |
| 259 |
|
]); |
| 260 |
|
} |
| 261 |
|
|
| 262 |
|
/** |
| 263 |
|
* For queries like http://localhost/NorthWind.svc/Orders(10643)/Customer. |
|
@@ 265-278 (lines=14) @@
|
| 262 |
|
/** |
| 263 |
|
* For queries like http://localhost/NorthWind.svc/Orders(10643)/Customer. |
| 264 |
|
*/ |
| 265 |
|
public function getRelatedResourceReference( |
| 266 |
|
ResourceSet $sourceResourceSet, |
| 267 |
|
$sourceEntityInstance, |
| 268 |
|
ResourceSet $targetResourceSet, |
| 269 |
|
ResourceProperty $targetProperty |
| 270 |
|
) { |
| 271 |
|
$entityClassName = $targetResourceSet->getResourceType()->getInstanceType()->name; |
| 272 |
|
$entityName = $this->getEntityName($entityClassName); |
| 273 |
|
$fieldName = $this->getTableName($entityName) . '_id'; |
| 274 |
|
|
| 275 |
|
return $this->getResource($targetResourceSet, null, [ |
| 276 |
|
'id' => $sourceEntityInstance->$fieldName, |
| 277 |
|
]); |
| 278 |
|
} |
| 279 |
|
} |
| 280 |
|
|