I develop university site with Symfony2. Besides I'm almost newbie in Symfony.
Index page consists of several blocks: news, events, photos, etc. All objects are fetched from webservices, so no DB is used directly.
I wonder which is better:
Please give me advice.
There cannot be a perfect obsolete answer for this question. Both ways are equally standard ways of coding in Symfony. Its a decision based approach which matters a lot.
Fetch all news,photos,.. objects in DefaultController:indexAction and pass them to index.html.twig as arguments -> when the data you are displaying/loading for the page is relatively less or belongs to one single module/feature. This way you have a simple process - route -> controller -> twig. Simple but sweet way of coding.
Call render(controller(News:block)) in index.html.twig. And NewsController in turn fetches objects and renders news_block.html.twig. -> Use this approach when your twig/page is rendering a lot of components or requires a lot of heavy lifting in one action. This will help you a lot in maintaining the code, as each part of your twig is rendered seperately using seperate controllers. Plus, this will also improve the site UX performance a little bit, because the twig is initially rendered with bare minimum information and then each individual component renders itself seperately using own controllers.