xdr*_*rew 5 symfony twig sonata-admin
将FOSMessageBundle集成到SonataAdminBundle时存在困难.我希望FOSMessage在Sonata的菜单下.所以我制作了FOSMessage的基本布局来扩展标准的奏鸣曲布局:
{% extends "::standard_layout.html.twig" %}
问题是奏鸣曲菜单需要一些额外的枝条变量,这些变量是在其基于CoreController的控制器中生成的:
array(
'base_template' => $this->getBaseTemplate(),
'admin_pool' => $this->container->get('sonata.admin.pool'),
'blocks' => $this->container->getParameter('sonata.admin.configuration.dashboard_blocks')
);
Run Code Online (Sandbox Code Playgroud)
有一种简单的方法可以为这些变量提供外部(FOSMessageBundle)模板吗?
找到了合适的解决方案。
在标准奏鸣曲布局中,替换所有菜单内容并将其放入简单控制器中的独立模板中:
{% render(controller('MyBundle:SonataMenu:index')) %}
Run Code Online (Sandbox Code Playgroud)
控制器:
namespace MyBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sonata\AdminBundle\Controller\CoreController;
class SonataMenuController extends CoreController
{
/**
* @Route("/admin/sonata_menu", name="sonata_menu")
* @Template()
*/
public function indexAction()
{
return array(
'admin_pool' => $this->container->get('sonata.admin.pool'),
);
}
}
Run Code Online (Sandbox Code Playgroud)
现在标准布局对于任何第三方继承都是免费的。
归档时间: |
|
查看次数: |
854 次 |
最近记录: |