Reputation: 37
I'm implementing a wizard-style process in my symfony application. It has additional buttons for 'back' and 'next' and I control which pages the user is directed to after each form is submitted.
I'd like some suggestions on how to lock down the routes once the user is in wizard mode i.e. if in wizard mode they can only access the 5 pages used in the wizard process. If they attempt to navigate to other routes while in wizard mode it redirects back to the last known route the wizard was in.
I could go into each action and add a redirect if in wizard mode but this seems like the wrong approach.
Upvotes: 0
Views: 151
Reputation: 1776
A Symfony filter is a good choice here.
Put myWizardFilter.class.php in your application lib folder:
class myWizardFilter extends sfFilter {
public function execute ($filterChain) {
if ($this->isFirstCall() && $wizardMode && $outsideWizard) {
$controller = $this->getContext()->getController();
$controller->forward('wizardModule', 'wizardAction');
throw new sfStopException();
}
$filterChain->execute();
}
}
$wizardMode
with whatever you check to see whether or not the user is in wizard mode.$outsideWizard
. Otherwise, you'll get a redirect loop.Then add the filter to your filters.yml:
wizard:
class: myWizardFilter
Upvotes: 1