title: Disable SonataUserBundle sonata.user.admin.group service
body: <p>I'm working with SonataAdminBundle and SonataUserBundle.</p>
  
  <p>SonataUserBundle registers a service <code>sonata.user.admin.group</code> which is automatically detected by SonataAdminBundle to set links in the admin dashboard to group CRUD operations.</p>
  
  <p>How can I disable <code>sonata.user.admin.group</code>? I've been following that recipes in Symfony2 documentation:</p>
  
  <ul>
  <li><p><a href="http://symfony.com/doc/master/cookbook/bundles/override.html#services-configuration" rel="nofollow">How to Override any Part of a Bundle - Services and Configuration</a></p></li>
  <li><p><a href="http://symfony.com/doc/master/components/dependency_injection/compilation.html#creating-a-compiler-pass" rel="nofollow">Compiling the Container - Creating a Compiler Pass</a></p></li>
  <li><p><a href="http://symfony.com/doc/master/components/dependency_injection/definitions.html" rel="nofollow">Working with Container Parameters and Definitions</a></p></li>
  </ul>
  
  <p>So far, I have the following code in my bundle definition to add a compiler pass:</p>
  
  <pre><code>public function build(ContainerBuilder $container)
  {
    parent::build($container);
  
    $container-&gt;addCompilerPass(new CompilerPass());
  }
  </code></pre>
  
  <p>And here it is the compiler pass:</p>
  
  <pre><code>&lt;?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-&gt;removeDefinition('sonata.user.admin.group');
      }
  }
  </code></pre>
  
  <p>I thought that this should work but no. Symfony is throwing an exception telling me that <code>sonata.user.admin.group</code> service does not exist. But it exists, and if I do <code>$container-&gt;getDefinition('sonata.user.admin.group')</code> the actual definition is return.</p>
  
  <p>Thanks</p>