Skip to content
Advertisement

Why can I not return a HTTP response from a private function in symfony?

I have a controller working like this’

JavaScript

But I would like to put that response-returning-business already in the private function to clean up my indexAction, but that is not possible, the indexAction will keep going past the point of

JavaScript

even if checkOpenEntries attempts to return a HTTP response.

Ideally I would like it to look like this, is there a way to accomplish that:

JavaScript

Advertisement

Answer

IMHO, it is not clean the way you mix up the type of method. However, you could do something like this, to make it work.

In addition, I think it would be better if functions and parameters have type, it would be easier to read.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement