Deployment services in branch templates

I use controllers as services and try to embed these controllers in a branch template using the following syntax:

{% render 'my_controller:thisAction' %} {% render 'my_controller2:this2Action' %} {% render 'my_controller3:this3Action' %} 

The problem is that instead of the correct analysis, only the first rendering operator is correctly processed, and the next ones are not.

Any suggestions why this issue is occurring?

+4
source share
1 answer

Just make sure the naming convention is respected. And you do not need your controller for maintenance. The controllers must capture the Request and return a Response .

Imagine you have a default controller.

 namespace Renoir\SiteBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; class DefaultController extends Controller { // ... public function randomNameRenderAction() { // Do some logic } } 

In a view that you could invoke using

 {% render 'RenoirSiteBundle:Default:randomNameRender' %} 
0
source

Source: https://habr.com/ru/post/1383017/


All Articles