title: Sonata Admin extending User admin class and not using generated bundle
body: <p>I had some trouble extending user admin when i tried to use the classes in my bundle and not in the generated bundle (Application/Sonata/UserBundle).
  I don't know if my solution is good but it works for me.</p>
  
  <p>Here is the procedure:</p>
  
  <ul>
  <li>First the config:</li>
  </ul>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>imports:
      - { resource: parameters.yml }
      - { resource: security.yml }
      - { resource: services.yml }
  
  framework:
      #esi:             ~
      #translator:      { fallback: "%locale%" }
      secret:          "%secret%"
      router:
          resource: "%kernel.root_dir%/config/routing.yml"
          strict_requirements: ~
      form:            ~
      csrf_protection: ~
      validation:      { enable_annotations: true }
      templating:
          engines: ['twig']
          #assets_version: SomeVersionScheme
      default_locale:  "%locale%"
      trusted_hosts:   ~
      trusted_proxies: ~
      session:
          # handler_id set to null will use default session handler from php.ini
          handler_id:  ~
      fragments:       ~
      http_method_override: true
  
  # Twig Configuration
  twig:
      debug:            "%kernel.debug%"
      strict_variables: "%kernel.debug%"
  
  # Assetic Configuration
  assetic:
      debug:          "%kernel.debug%"
      use_controller: false
      bundles:        [ ]
      #java: /usr/bin/java
      filters:
          cssrewrite: ~
          #closure:
          #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
          #yui_css:
          #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
  
  # Doctrine Configuration
  doctrine:
      dbal:
          driver:   "%database_driver%"
          host:     "%database_host%"
          port:     "%database_port%"
          dbname:   "%database_name%"
          user:     "%database_user%"
          password: "%database_password%"
          charset:  UTF8
          # if using pdo_sqlite as your database driver:
          #   1. add the path in parameters.yml
          #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
          #   2. Uncomment database_path in parameters.yml.dist
          #   3. Uncomment next line:
          #     path:     "%database_path%"
          # added for sonata user
          types:
              json: Sonata\Doctrine\Types\JsonType
  
      orm:
          auto_generate_proxy_classes: "%kernel.debug%"
          # added for sonata user
          entity_managers:
              default:
                  mappings:
                      SonataUserBundle: ~
                      FOSUserBundle: ~
                  auto_mapping: true
  
  # Swiftmailer Configuration
  swiftmailer:
      transport: "%mailer_transport%"
      host:      "%mailer_host%"
      username:  "%mailer_user%"
      password:  "%mailer_password%"
      spool:     { type: memory }
  #  FosRest configuration
  fos_rest:
      view:
          formats:
              rss: false
              xml: false
          templating_formats:
              html: true
          force_redirects:
              html: true
          failed_validation: HTTP_BAD_REQUEST
          default_engine: twig
  # SonataAdmin configuration
  sonata_block:
      default_contexts: [cms]
      blocks:
          # Enable the SonataAdminBundle block
          sonata.admin.block.admin_list:
              contexts:   [admin]
          sonata.user.block.menu:    # used to display the menu in profile pages
          sonata.user.block.account: # used to display menu option (login option)
  
  sonata_user:
      security_acl: false
      manager_type: orm # can be orm or mongodb
      class:
          user: Wf\Bundle\TestsBundle\Entity\User
          group: Wf\Bundle\TestsBundle\Entity\Group
      admin:
          user:
              class:          Wf\Bundle\TestsBundle\Admin\UserAdmin
              controller:     SonataAdminBundle:CRUD
              translation:    SonataUserBundle
          group:
              class:          Wf\Bundle\TestsBundle\Admin\GroupAdmin
              controller:     SonataAdminBundle:CRUD
              translation:    SonataUserBundle
  
  fos_user:
      db_driver:      orm # can be orm or odm
      firewall_name:  main
      user_class:     Wf\Bundle\TestsBundle\Entity\User
      # use this option when easy extending the bundle (app/console sonata:easy-extends:generate SonataUserBundle --dest=src)
      #user_class:     Sonata\UserBundle\Entity\BaseUser
      group:
          group_class:   Wf\Bundle\TestsBundle\Entity\Group
          #group_class:   Sonata\UserBundle\Entity\BaseGroup
          group_manager: sonata.user.orm.group_manager
      service:
          user_manager: sonata.user.orm.user_manager</code></pre>
  </div>
  </div>
  </p>
  
  <ul>
  <li>UserAdmin class; same with GroupAdmin class </li>
  </ul>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  /**
   * Created by razvan.
   * Date: 1/16/15
   * Time: 1:53 PM
   */
  
  namespace Wf\Bundle\TestsBundle\Admin;
  
  use Sonata\UserBundle\Admin\Model\UserAdmin as BaseUserAdmin;
  
  use Sonata\AdminBundle\Form\FormMapper;
  use Sonata\AdminBundle\Datagrid\DatagridMapper;
  use Sonata\AdminBundle\Datagrid\ListMapper;
  use Sonata\AdminBundle\Show\ShowMapper;
  
  use FOS\UserBundle\Model\UserManagerInterface;
  use Sonata\AdminBundle\Route\RouteCollection;
  
  
  class UserAdmin extends BaseUserAdmin
  {
      /**
       * {@inheritdoc}
       */
      protected function configureShowFields(ShowMapper $showMapper)
      {
          $showMapper
              -&gt;with('General')
              -&gt;add('username')
              -&gt;add('email')
              -&gt;end()
              // .. more fields
          ;
      }
  
      /**
       * {@inheritdoc}
       */
      protected function configureFormFields(FormMapper $formMapper)
      {
  
          $formMapper
              -&gt;with('User data')
              -&gt;add('username')
              -&gt;add('email')
              -&gt;add('plainPassword', 'text', array('required' =&gt; false))
              -&gt;end()
              // .. more fields
          ;
  
          if (!$this-&gt;getSubject()-&gt;hasRole('ROLE_SUPER_ADMIN')) {
              $formMapper
                  -&gt;with('Management')
                  -&gt;add('roles', 'sonata_security_roles', array(
                      'expanded' =&gt; true,
                      'multiple' =&gt; true,
                      'required' =&gt; false
                  ))
                  -&gt;add('locked', null, array('required' =&gt; false))
                  -&gt;add('expired', null, array('required' =&gt; false))
                  -&gt;add('enabled', null, array('required' =&gt; false))
                  -&gt;add('credentialsExpired', null, array('required' =&gt; false))
                  -&gt;end()
              ;
          }
      }
  
      /**
       * {@inheritdoc}
       */
      protected function configureDatagridFilters(DatagridMapper $filterMapper)
      {
          $filterMapper
              -&gt;add('id')
              -&gt;add('username')
              -&gt;add('locked')
              -&gt;add('email')
          ;
      }
      /**
       * {@inheritdoc}
       */
      protected function configureListFields(ListMapper $listMapper)
      {
        // overide defaults
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <ul>
  <li>User class; same wirh Group class</li>
  </ul>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  
  namespace Wf\Bundle\TestsBundle\Entity;
  
  use Sonata\UserBundle\Entity\BaseUser as BaseUser;
  use Doctrine\ORM\Mapping as ORM;
  
  
  /**
   * Class User
   * @package Wf\Bundle\TestsBundle\Entity
   *
   * @ORM\Table(name="fos_user_user")
   * @ORM\Entity()
   */
  class User extends BaseUser
  {
      /**
       * @var integer $id
       *
       * @ORM\Id()
       * @ORM\GeneratedValue(strategy="AUTO")
       * @ORM\Column(type="integer")
       */
      protected $id;
  
      /**
       * Get id
       *
       * @return integer $id
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Now in Resources\config create a folder named "doctrine" and then add the folowing files:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>First file is named Group.orm.xml
  
  Inser the following into the file
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                    http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"&gt;
  
      &lt;entity name="Wf\Bundle\TestsBundle\Entity\Group" table="fos_user_group"&gt;
  
          &lt;id name="id" column="id" type="integer"&gt;
              &lt;generator strategy="AUTO" /&gt;
          &lt;/id&gt;
  
      &lt;/entity&gt;
  
  &lt;/doctrine-mapping&gt;
  
  Second file is User.orm.xml
  
  Insert the following:
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                    http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"&gt;
  
      &lt;entity name="Wf\Bundle\TestsBundle\Entity\User" table="fos_user_user"&gt;
  
          &lt;id name="id" column="id" type="integer"&gt;
              &lt;generator strategy="AUTO" /&gt;
          &lt;/id&gt;
  
      &lt;/entity&gt;
  
  &lt;/doctrine-mapping&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Be careful to change the path to your own and clear the cache.</p>