Zend Framework
- 1 ответ
- 0 вопросов
1
Вклад в тег
namespace Api\V1\Rpc\Version;
use Zend\Mvc\Controller\AbstractActionController;
use ZF\ContentNegotiation\ViewModel;
class VersionController extends AbstractActionController
{
public function versionAction()
{
$hal = $this->getPluginManager()->get('hal');
$o = $hal->createEntityFromMetadata(
new Entity(),
$hal->getMetadataMap()->get('Api\\V1\\Rpc\\Version\\Entity')
);
return new ViewModel(array(
'payload' => $o
));
}
}
namespace Api\V1\Rpc\Version;
class Entity
{
public $version = 1;
}
'zf-hal' => array(
'metadata_map' => array(
'Api\\V1\\Rpc\\Version\\Entity' => array(
'route_name' => 'api.rpc.version',
'entity_identifier_name' => 'version',
'route_identifier_name' => 'version_id',
'hydrator' => 'Zend\\Stdlib\\Hydrator\\ObjectProperty',
),
namespace Api\V1\Rpc\Version;
use Zend\Mvc\Controller\AbstractActionController;
class VersionController extends AbstractActionController
{
public function versionAction()
{
return ['version'=>1];
}
}
namespace Api\V1\Rest\Version;
use ZF\Rest;
class VersionController extends Rest\RestController {
protected function getIdentifier($routeMatch, $request)
{
return 'version';
}
}
namespace Api\V1\Rest\Version;
class Entity
{
public $version = 1;
}
namespace Api\V1\Rest\Version;
use ZF\Rest\AbstractResourceListener;
class VersionResource extends AbstractResourceListener
{
public function fetch($id)
{
return new Entity();
}
}