Created
September 25, 2014 14:06
-
-
Save weierophinney/2c47c9d59f4a5214f0c3 to your computer and use it in GitHub Desktop.
One way to return a HAL entity from an Apigility RPC controller.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function someAction() | |
{ | |
$data = doSomeWorkFetchSomeData(); | |
$entity = new \ZF\Hal\Entity($data, $data['id']); // or similar | |
return new \ZF\ContentNegotiation\ViewModel([ | |
'payload' => $entity, | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you havn't defined a REST service for the entity you want to return, you might need to configure the
metadata map
by hand