0
votes

Could not find an answere here in so. Hope I didn't missed it.

I tried, but couldn't find a way to get the route by a given controller and action inf ZF2. I want to build an admin page for acls and I want to display the route for the resource. I build the resource dynamically from Module/Controller/Action names.

Lets say I have a Controller named Application and an action named testAction. In my module.config.php is the route /application[:/action] defined. Now I want to ask ZF2, which route has the controller "Application" with the method testAction and the result should be application/test.

Is this possible somehow?

2
framework.zend.com/manual/2.0/en/modules/… The module manager prob has a few listeners you could use for that.cptnk

2 Answers

0
votes

It is impossible from any practical standpoint.

It is side effect of flexibility of routing in zf2. You can try to apply heavily limiting conventions for your routes, but that would be neither reliable or good decision.

0
votes

Not sure if I understand correctly what you are trying to do.

while in controller application you can get current controller and action,

$controller = $this->params('controller');
$action = $this->params('action');

If this is not what you want please give more information.

Then would this help you?

$config = $this->getServiceLocator()->get('Config');
print_r($config['router']);die;