Closed mickaelandrieu closed 4 years ago
More food for the brain... how can we use the Grid component here while keeping the compatibility on templates and hooks...?
Gains => Every Grid works the exact same way Pros => I'm not sure we can keep retro compatibility on templating ... WDYT @eternoendless ?
catalogAction
explainedThis action is in charge of rendering the Product list page, except for the list of products rendered by
listAction
. This controller has so (too?!) many responsibilities:What I suggest
Task 1 can be done before entering the controller thanks to
KernelEvents::CONTROLLER
event. More, this can be re-used for almost every action of Symfony pages.Task 2 is useless as it's done by default by the
UserLocaleListener
=> To be removedTask 3, 4 and 9 should be done once and for all using a new Immutable object call
ProductsFilters
that we retrieve directly as catalog Action arguments. This may change the behavior in case of Task 9 but remember, the list of products is retrieved later using list actions...Task 5 and 6 can stay in
catalogAction
but improved. Something like:Make so much sense here: more, the service should be immutable and for me, it feels so wrong to store the last executed SQL query inside the service!
Task 7 should be handled by a specific action and can be done before the controller thanks to
KernelEvents::CONTROLLER
event. This listener is - of course - specific to theProductController
.Task 8 should of course stay in
catalogAction
but we don't need the "if" statement anymore :)Task 10 is useless, the session can be accessed from twig so only a minor update of the related template.
For Task 11, I don't know... because I don't know why it's needed: if it's only to display/hide something in front, this is something that can be managed in Twig.
Cool, but why do we want to do it?
Many reasons: