1
votes

Have searched for this but i'm coming up short. What is the best way to restrict access to an action in a controller in ZF2? What i want is to only call a certain action in a controller (which is in a different module) if the request comes from a specific action - if not redirect to 404. I see that i can use

$this->getRequest()->getUri()->getPath()

to get the current URL, but what i want is the previous one? I could put this in a session variable, or pass it as a parameter in the route but is there a better way? Reason is that i have a multi step form and i wish to only allow step 2 if the user came from step 1, otherwise 404.

What is the recommended ZF2 practice for this? thanks

1

1 Answers

1
votes

You should probably not handle this via urls. I'd look into Zend\Session\Container to manage state explicitly after you submit the first form.