For my current Application Setup i am trying to create a routing for Standard Controllers and Rest Controllers.
This is my Structure.
/application
/modules
/module
/controllers
/Admin
/Api
To call a Controller within the admin Sub Folder:
/module/admin_controller/action
I want to change this to:
/admin/module/controller/action
In my current setup:
/* application.ini */
;Default route
resources.router.routes.defaultmodule.type = Zend_Controller_Router_Route_Module
resources.router.routes.defaultmodule.defaults.module = "default
; APi route
resources.router.routes.api.type = Zend_Controller_Router_Route
resources.router.routes.api.route = ":api"
resources.router.routes.api.reqs.api = "api"
resources.router.routes.apichain.type = Zend_Controller_Router_Route_Chain
resources.router.routes.apichain.chain = "api, defaultmodule"
; Admin route
resources.router.routes.admin.type = Zend_Controller_Router_Route
resources.router.routes.admin.route = ":admin"
resources.router.routes.admin.reqs.admin = "admin"
resources.router.routes.adminchain.type = Zend_Controller_Router_Route_Chain
resources.router.routes.adminchain.chain = "admin, defaultmodule"
/* Plugin */
class Pwb_Plugin_ControllerRoute
extends Zend_Controller_Plugin_Abstract
{
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
if ($request->getParam('admin')) {
$admin_controller = $request->getParam('admin') . '_' . $request->getControllerName();
$request->setControllerName($admin_controller);
}
if ($request->getParam('api')) {
$admin_controller = $request->getParam('api') . '_' . $request->getControllerName();
$request->setControllerName($admin_controller);
}
}
}
/* Module Bootstrap */
class Acl_Bootstrap
extends Zend_Application_Module_Bootstrap
{
protected function _initRestRoute()
{
$this->bootstrap('frontController');
$frontController = Zend_Controller_Front::getInstance();
$restRoute = new Zend_Rest_Route(
$frontController,
array(),
array(
'acl' => array(
'api_role'
))
);
$frontController->getRouter()->addRoute('restAcl', $restRoute);
}
}
The issue here really is that some Controllers in the API folder are Rest but not all of them.
/api/acl/role is routing correctly to the indexAction as expected.
/api/acl/role/1 is looking for the action "1" where i would expect it to route to getAction.
How could i integrate the Zend_Route_Rest from the module Bootstrap into these rulesets.
Every help would be much appreciated.