Created
May 20, 2014 15:38
-
-
Save ezimuel/e2b528ba160197d0c773 to your computer and use it in GitHub Desktop.
RPC with HAL JSON
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 | |
namespace Test\V1\Rpc\Test; | |
use Zend\Mvc\Controller\AbstractActionController; | |
use ZF\ContentNegotiation\ViewModel; | |
use ZF\Hal\Entity; | |
use ZF\Hal\Link\Link; | |
class TestController extends AbstractActionController | |
{ | |
public function testAction() | |
{ | |
$id = 1; | |
$data = array ( 'name' => 'Enrico Zimuel', 'id' => $id ); | |
$entity = new Entity($data, $id); | |
$entity->getLinks()->add(Link::factory(array( | |
'rel' => 'contacts', | |
'route' => array( | |
'name' => 'test.rest.user', | |
) | |
))); | |
return new ViewModel(array( | |
'payload' => $entity | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think we can add this information in this recipe https://www.apigility.org/documentation/recipes/hal-from-rpc, what do you think?