Is it advisable to use several render controllers in a view? [closed]

0

I have a view that represents a dashboard, in it I include several panels with dynamically calculable data, to show each panel I use the render method (controller (...)). Is it advisable to do it this way, or to calculate all the data in the view controller?

    
asked by Francisco 13.04.2017 в 18:51
source

1 answer

1

Although it could be interpreted as a response based on opinions, the fact is that the official symfony manual Advises its use.

  

Whenever you find that you need a variable or a piece of information that you do not have access to in a template, consider rendering a controller. Controllers are fast to execute and promote good code organization and reuse. Of course, like all controllers, they should ideally be "skinny", meaning that as much as possible lives in reusable services.

That comes to mean

  

Whenever you find that you need a variable or piece of information that you do not have access to from a template, consider processing a driver. The controllers are quick to execute and promote the organization of good code and its reuse. Of course, like all controllers, they should ideally be "small", which means that as much code as possible should stay in reusable services.

That said, it is totally logical and of extended use to create methods in controllers to generate pieces of code when these are going to be used in several places of your application.

But if on the contrary, you are only going to show them in the "dashboard" of your application, it might be easier to load all the values from the controller, and organize each block in templates using it using blocks of type include

    
answered by 18.04.2017 / 09:17
source