i need your advice. I need to create multiple Actions in RPC style API Controller generated by Apigility. How do I need to make routing, to make it work like it is in normal zend application.
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',/*I need flexible route like this one*/
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
Code generated by Apigility is:
<?php
namespace TestAPI\V1\Rpc\Test;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
class TestController extends AbstractActionController
{
public function TestAction()
{
/*Added by myself*/
return new JsonModel(array(
'id' => 'test',
));
}
}
and routing is generated this way:
'controllers' => array(
'factories' => array(
'TestAPI\\V1\\Rpc\\Test\\Controller' => 'TestAPI\\V1\\Rpc\\Test\\TestControllerFactory',
),
),
'zf-rpc' => array(
'TestAPI\\V1\\Rpc\\Test\\Controller' => array(
'service_name' => 'test',
'http_methods' => array(
0 => 'GET',
),
'route_name' => 'test-api.rpc.test',
),
),
Thank You for your help!
Solution 1
Try register aliases on controllers key to your controller and register each alias on zf-rpc config.
Something like that:
Probably you have to copy and change de route config and another configs.
Solution 2
You can try generate another rpc service and change the factory to a alias, all configs will generate to you.
after you generate the service, you will get something like this:
You have to change to something like this: