vendor/sonata-project/user-bundle/src/SonataUserBundle.php line 25

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the Sonata Project package.
  5.  *
  6.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Sonata\UserBundle;
  12. use Sonata\CoreBundle\Form\FormHelper;
  13. use Sonata\UserBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass;
  14. use Sonata\UserBundle\DependencyInjection\Compiler\RolesMatrixCompilerPass;
  15. use Symfony\Component\DependencyInjection\ContainerBuilder;
  16. use Symfony\Component\HttpKernel\Bundle\Bundle;
  17. /**
  18.  * @final since sonata-project/user-bundle 4.15
  19.  */
  20. class SonataUserBundle extends Bundle
  21. {
  22.     public function build(ContainerBuilder $container): void
  23.     {
  24.         $container->addCompilerPass(new GlobalVariablesCompilerPass());
  25.         $container->addCompilerPass(new RolesMatrixCompilerPass());
  26.         $this->registerFormMapping();
  27.     }
  28.     public function boot(): void
  29.     {
  30.         $this->registerFormMapping();
  31.     }
  32.     /**
  33.      * Register form mapping information.
  34.      *
  35.      * NEXT_MAJOR: remove this method
  36.      */
  37.     public function registerFormMapping(): void
  38.     {
  39.         if (class_exists(FormHelper::class)) {
  40.             FormHelper::registerFormTypeMapping([
  41.                 'fos_user_username' => 'FOS\UserBundle\Form\Type\UsernameFormType',
  42.                 'fos_user_profile' => 'FOS\UserBundle\Form\Type\ProfileFormType',
  43.                 'fos_user_registration' => 'FOS\UserBundle\Form\Type\RegistrationFormType',
  44.                 'fos_user_change_password' => 'FOS\UserBundle\Form\Type\ChangePasswordFormType',
  45.                 'fos_user_resetting' => 'FOS\UserBundle\Form\Type\ResettingFormType',
  46.                 'fos_user_group' => 'FOS\UserBundle\Form\Type\GroupFormType',
  47.                 'sonata_security_roles' => 'Sonata\UserBundle\Form\Type\SecurityRolesType',
  48.                 'sonata_user_profile' => 'Sonata\UserBundle\Form\Type\ProfileType',
  49.                 'sonata_user_gender' => 'Sonata\UserBundle\Form\Type\UserGenderListType',
  50.                 'sonata_user_registration' => 'Sonata\UserBundle\Form\Type\RegistrationFormType',
  51.                 'sonata_user_api_form_group' => 'Sonata\UserBundle\Form\Type\ApiGroupType',
  52.                 'sonata_user_api_form_user' => 'Sonata\UserBundle\Form\Type\ApiUserType',
  53.             ]);
  54.         }
  55.     }
  56. }