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

Remove parameters from send() #11

Open
PetrHudik opened this issue May 7, 2015 · 5 comments
Open

Remove parameters from send() #11

PetrHudik opened this issue May 7, 2015 · 5 comments

Comments

@PetrHudik
Copy link

I don't underestant why in send() method are two parameters. You don't use it anyway.

In my opintion, it will be better just without or with default value:

    /**
     * Sends response to output.
     * @return void
     */
    public function send(IRequest $httpRequest = NULL, IResponse $httpResponse = NULL) {
        // ...
    }

Then you can use it anywhare without unnecessary dependencies:

        $template = $this->createTemplate()->setFile( /* ... */ );
        $template->data = $data;
        $pdf = new PdfResponse($template);
        $pdf->outputName = $fileName; 
        $pdf->outputDestination = PdfResponse::OUTPUT_FILE;
        $pdf->send();

Maybe I just missing something important.

@jkuchar
Copy link
Owner

jkuchar commented May 7, 2015

;-) This the answer: http://api.nette.org/2.0.18/Nette.Application.IResponse.html

But yes, it looks like good ideat to extract content of that method to another one (e.g. sendResponse()). What do you think?

@PetrHudik
Copy link
Author

Thanks for quik reply.

Yes, extracting to another method works for me.

@jkuchar
Copy link
Owner

jkuchar commented May 7, 2015

Could you please send PR? :)

@PetrHudik
Copy link
Author

Sure, I'll do my best. But it will be done next week.

@PetrHudik
Copy link
Author

So, I've worked on this and here is result:

  1. In my opinion, the best solution is just add default values to function. I think you CAN have default values in function implementing interface. So, here is my solution:

PetrHudik@83e83fe

  1. Here's suggested solution - extracting content to another method:

PetrHudik@d3ace7b

  1. While i was working with saving files, function saveFile() can be handy:

PetrHudik@3a41981

What do you think? Witch solution is best for you?

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

No branches or pull requests

2 participants