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

Added possibility to store other request then the current one #1219

Closed
wants to merge 1 commit into from

Conversation

enumag
Copy link
Contributor

@enumag enumag commented Aug 28, 2013

I'd like to store the request in ErrorPresenter like this:

final class ErrorPresenter extends BasePresenter
{
    public function renderDefault($exception, $request)
    {
        // ...
        $this->storeRequest('+ 10 minutes', $request);
        // ...
    }
}

@Majkl578
Copy link
Contributor

👍 for the feature, but 👎 for implementation as it looks too hacky. storeRequest($request, $expiration) would make much more sense to me, but the method would do a magic.

@enumag
Copy link
Contributor Author

enumag commented Aug 29, 2013

@Majkl578 Huh? How would you implement it then? I'm actually thinking about hacking it even more so that the first parameter would be optional.

EDIT: Yeah, switching the parameters order probably would be better. (I've thought about that as well actually.)

@dg Which way do you want me to implement it?

@dg
Copy link
Member

dg commented Aug 29, 2013

storeRequest($request, $expiration) is better.

@enumag
Copy link
Contributor Author

enumag commented Aug 29, 2013

@Majkl578 Is it ok now in your opinion? :-)

{
// first parameter is optional
if ($request !== NULL && !$request instanceof Application\Request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

NULL check is unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is necessary because of a call with no parameters. The default expiration would be overwritten with the NULL.

@enumag
Copy link
Contributor Author

enumag commented Aug 29, 2013

@Majkl578 What about this then?

        if ($request === NULL) {
            $request = $this->request;
        } elseif (!$request instanceof Application\Request) {
            $expiration = $request;
            $request = $this->request;
        }

@enumag
Copy link
Contributor Author

enumag commented Aug 29, 2013

@dg Majkl and I both think this other way is more readable so I force-pushed it. It's ready to merge imho.

@enumag
Copy link
Contributor Author

enumag commented Sep 17, 2013

ping @dg

@enumag
Copy link
Contributor Author

enumag commented Oct 16, 2013

Fixed typo in commit message.

@enumag
Copy link
Contributor Author

enumag commented Nov 29, 2013

I realized that the logic I had in ErrorPresenter shouldn't be there so I moved that elsewhere making this feature useless.

@enumag enumag closed this Nov 29, 2013
@Majkl578
Copy link
Contributor

@enumag: It is not useless for me, so could you please reopen it?

@enumag
Copy link
Contributor Author

enumag commented Nov 29, 2013

@Majkl578 ok

@enumag enumag reopened this Nov 29, 2013
@Majkl578
Copy link
Contributor

One mine use case is indirect redirect - e.g. fill in a form, save it to session, then redirect to authentication and afterwards go back directly to next step, say, saving form data from session to database.

@dg
Copy link
Member

dg commented Jun 24, 2014

storeRequest will be moved outside from Presenter. nette/application#4

@dg dg closed this Jun 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants