-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle $redirect to a route with parameters #469
Conversation
Test $redirect by trying to match it to a route, which enables passing $redirect that contains parameters. If match() returns NULL then we assume the $redirect parameter contains a named route, as was the case prior to this commit.
Didn't test it but seems good. |
Yeah... I'm kinda new at this so was trying to touch as few parts of code as possible to get something at least functional, with a view to making it more efficient/Dry/whatever later. |
In also not a pro at zf2. |
Split out previous commit as a new function redirectToRoute($redirect) that handles strings containing either route name or route with parameters.
ok, now it is in a function. |
**/ | ||
$router = $this->getServiceLocator()->get('router'); | ||
$redirectRequest = new Request(); | ||
$redirectRequest->setMethod(Request::METHOD_POST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The request should be GET
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to GET.
Changed from METHOD_POST to METHOD_GET on advice from @ojhaujjwal.
After validating that $redirect matches a route within the application, we know it is not a url to an external site, so can simplify the code by using toUrl().
Please add tests. |
Don't know how to do that yet, could be some time while I learn. |
I released v. 1.2.0 of ZfcUser which makes it possible to change the redirect callback. Check #487 for more info. |
Test $redirect by trying to match it to a route, which enables passing $redirect that contains parameters. If match() returns NULL then we assume the $redirect parameter contains a named route, as was the case prior to this commit.