Symfony 继承无效 EasyAdmin 包
Symfony inheritance isn't working EasyAdmin bundle
我正在使用带有 EasyAdminBundle 的 symfony 3
我创建了一个名为 AdminBundle 的新包,它是 EasyAdminBundle 的子项(用于覆盖)
namespace AdminBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AdminBundle extends Bundle {
public function getParent(){
return 'EasyAdminBundle';
}
}
我重写了控制器中的一个方法并且它工作正常,但是当我试图重写一个树枝模板时它不起作用...
我在 AdminBundle/Resources/views/default/list.html.twig
中创建了我的树枝文件
原文在vendor/javiereguiluz/easyadmin-bundle/Resources/views/default/list.html.twig
如何解决?
(我清除了很多次缓存...)
渲染 EasyAdminBundle:default:index.html.twig
时,Symfony 实际上会在两个不同的位置查找模板:
- app/Resources/EasyAdminBundle/views/default/index.html.twig
- src/AdminBundle/Resources/views/default/index.html.twig
您的方法是第二种选择,但是:
The overriding of resources only works when you refer to resources with the @FOSUserBundle/Resources/config/routing/security.xml
method. If you refer to resources without using the @BundleName shortcut, they can't be overridden in this way. [See Doc]
要覆盖包模板,只需将 index.html.twig
模板从包复制到 app/Resources/EasyAdminBundle/views/default/index.html.twig
(app/Resources/EasyAdminBundle
目录不存在,因此您需要创建它). [See Doc]
If you add a template in a new location, you may need to clear your cache (php bin/console cache:clear
), even if you are in debug mode.
我正在使用带有 EasyAdminBundle 的 symfony 3
我创建了一个名为 AdminBundle 的新包,它是 EasyAdminBundle 的子项(用于覆盖)
namespace AdminBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AdminBundle extends Bundle {
public function getParent(){
return 'EasyAdminBundle';
}
}
我重写了控制器中的一个方法并且它工作正常,但是当我试图重写一个树枝模板时它不起作用...
我在 AdminBundle/Resources/views/default/list.html.twig
原文在vendor/javiereguiluz/easyadmin-bundle/Resources/views/default/list.html.twig
如何解决? (我清除了很多次缓存...)
渲染 EasyAdminBundle:default:index.html.twig
时,Symfony 实际上会在两个不同的位置查找模板:
- app/Resources/EasyAdminBundle/views/default/index.html.twig
- src/AdminBundle/Resources/views/default/index.html.twig
您的方法是第二种选择,但是:
The overriding of resources only works when you refer to resources with the
@FOSUserBundle/Resources/config/routing/security.xml
method. If you refer to resources without using the @BundleName shortcut, they can't be overridden in this way. [See Doc]
要覆盖包模板,只需将 index.html.twig
模板从包复制到 app/Resources/EasyAdminBundle/views/default/index.html.twig
(app/Resources/EasyAdminBundle
目录不存在,因此您需要创建它). [See Doc]
If you add a template in a new location, you may need to clear your cache (
php bin/console cache:clear
), even if you are in debug mode.