Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

cpa99dcs
Copy link

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.

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.
cpa99dcs referenced this pull request Jun 19, 2014
@stijnhau
Copy link

Didn't test it but seems good.
The only i have is that that added could could better placed in a separate function.
I'm not a fan of double code.

@cpa99dcs
Copy link
Author

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.

@stijnhau
Copy link

In also not a pro at zf2.
Because it shouldn't be a function but rather a function of ...
Hoping one of the pros fills in the blanks. ;-)

Split out previous commit as a new function redirectToRoute($redirect) that handles strings containing either route name or route with parameters.
@cpa99dcs
Copy link
Author

ok, now it is in a function.

**/
$router = $this->getServiceLocator()->get('router');
$redirectRequest = new Request();
$redirectRequest->setMethod(Request::METHOD_POST);
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to GET.

cpa99dcs added 2 commits June 20, 2014 09:18
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().
@ojhaujjwal
Copy link
Contributor

Please add tests.

@cpa99dcs
Copy link
Author

Don't know how to do that yet, could be some time while I learn.

This was referenced Jul 2, 2014
@Danielss89
Copy link
Member

I released v. 1.2.0 of ZfcUser which makes it possible to change the redirect callback. Check #487 for more info.

@Danielss89 Danielss89 closed this Jul 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants