我正在使用 SonataAdminBundle 和 SonataUserBundle。
SonataUserBundle 注册了一项服务,该服务sonata.user.admin.group
由 SonataAdminBundle 自动检测,以在管理仪表板中设置链接以对 CRUD 操作进行分组。
我该如何禁用sonata.user.admin.group
?我一直在关注 Symfony2 文档中的那些食谱:
到目前为止,我的包定义中有以下代码来添加编译器通道:
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new CompilerPass());
}
这是编译器传递:
<?php
namespace NS\Service\CompilerPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class CompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$container->removeDefinition('sonata.user.admin.group');
}
}
I thought that this should work but no. Symfony is throwing an exception telling me that sonata.user.admin.group
service does not exist. But it exists, and if I do $container->getDefinition('sonata.user.admin.group')
the actual definition is return.
Thanks