SonataUserBundle.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\UserBundle;
  11. use Sonata\CoreBundle\Form\FormHelper;
  12. use Sonata\UserBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\HttpKernel\Bundle\Bundle;
  15. class SonataUserBundle extends Bundle
  16. {
  17. protected $parent;
  18. /**
  19. * @param string $parent
  20. */
  21. public function __construct($parent = null)
  22. {
  23. $this->parent = $parent;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function getParent()
  29. {
  30. return $this->parent;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function build(ContainerBuilder $container)
  36. {
  37. $container->addCompilerPass(new GlobalVariablesCompilerPass());
  38. $this->registerFormMapping();
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function boot()
  44. {
  45. $this->registerFormMapping();
  46. }
  47. /**
  48. * Register form mapping information.
  49. */
  50. public function registerFormMapping()
  51. {
  52. FormHelper::registerFormTypeMapping(array(
  53. 'fos_user_username' => 'FOS\UserBundle\Form\Type\UsernameFormType',
  54. 'fos_user_profile' => 'FOS\UserBundle\Form\Type\ProfileFormType',
  55. 'fos_user_registration' => 'FOS\UserBundle\Form\Type\RegistrationFormType',
  56. 'fos_user_change_password' => 'FOS\UserBundle\Form\Type\ChangePasswordFormType',
  57. 'fos_user_resetting' => 'FOS\UserBundle\Form\Type\ResettingFormType',
  58. 'fos_user_group' => 'FOS\UserBundle\Form\Type\GroupFormType',
  59. 'sonata_security_roles' => 'Sonata\UserBundle\Form\Type\SecurityRolesType',
  60. 'sonata_user_profile' => 'Sonata\UserBundle\Form\Type\ProfileType',
  61. 'sonata_user_gender' => 'Sonata\UserBundle\Form\Type\UserGenderListType',
  62. 'sonata_user_registration' => 'Sonata\UserBundle\Form\Type\RegistrationFormType',
  63. 'sonata_user_api_form_group' => 'Sonata\UserBundle\Form\Type\ApiGroupType',
  64. 'sonata_user_api_form_user' => 'Sonata\UserBundle\Form\Type\ApiUserType',
  65. ));
  66. }
  67. }