vendor/sonata-project/admin-bundle/src/SonataAdminBundle.php line 45

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\AdminBundle;
  12. use Mopa\Bundle\BootstrapBundle\Form\Type\TabType;
  13. use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
  14. use Sonata\AdminBundle\DependencyInjection\Compiler\AddFilterTypeCompilerPass;
  15. use Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass;
  16. use Sonata\AdminBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass;
  17. use Sonata\AdminBundle\DependencyInjection\Compiler\ModelManagerCompilerPass;
  18. use Sonata\AdminBundle\DependencyInjection\Compiler\ObjectAclManipulatorCompilerPass;
  19. use Sonata\AdminBundle\Form\Type\AdminType;
  20. use Sonata\AdminBundle\Form\Type\ChoiceFieldMaskType;
  21. use Sonata\AdminBundle\Form\Type\CollectionType;
  22. use Sonata\AdminBundle\Form\Type\Filter\ChoiceType;
  23. use Sonata\AdminBundle\Form\Type\Filter\DateRangeType;
  24. use Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType;
  25. use Sonata\AdminBundle\Form\Type\Filter\DateTimeType;
  26. use Sonata\AdminBundle\Form\Type\Filter\DateType;
  27. use Sonata\AdminBundle\Form\Type\Filter\DefaultType;
  28. use Sonata\AdminBundle\Form\Type\Filter\NumberType;
  29. use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
  30. use Sonata\AdminBundle\Form\Type\ModelHiddenType;
  31. use Sonata\AdminBundle\Form\Type\ModelListType;
  32. use Sonata\AdminBundle\Form\Type\ModelReferenceType;
  33. use Sonata\AdminBundle\Form\Type\ModelType;
  34. use Sonata\CoreBundle\Form\FormHelper;
  35. use Symfony\Component\DependencyInjection\ContainerBuilder;
  36. use Symfony\Component\HttpKernel\Bundle\Bundle;
  37. /**
  38.  * @final since sonata-project/admin-bundle 3.52
  39.  */
  40. class SonataAdminBundle extends Bundle
  41. {
  42.     public function build(ContainerBuilder $container)
  43.     {
  44.         $container->addCompilerPass(new AddDependencyCallsCompilerPass());
  45.         $container->addCompilerPass(new AddFilterTypeCompilerPass());
  46.         $container->addCompilerPass(new ExtensionCompilerPass());
  47.         $container->addCompilerPass(new GlobalVariablesCompilerPass());
  48.         $container->addCompilerPass(new ModelManagerCompilerPass());
  49.         $container->addCompilerPass(new ObjectAclManipulatorCompilerPass());
  50.         $this->registerFormMapping();
  51.     }
  52.     public function boot()
  53.     {
  54.         $this->registerFormMapping();
  55.     }
  56.     /**
  57.      * Register form mapping information.
  58.      */
  59.     public function registerFormMapping()
  60.     {
  61.         FormHelper::registerFormTypeMapping([
  62.             'sonata_type_admin' => AdminType::class,
  63.             'sonata_type_model' => ModelType::class,
  64.             'sonata_type_model_list' => ModelListType::class,
  65.             'sonata_type_model_reference' => ModelReferenceType::class,
  66.             'sonata_type_model_hidden' => ModelHiddenType::class,
  67.             'sonata_type_model_autocomplete' => ModelAutocompleteType::class,
  68.             'sonata_type_native_collection' => CollectionType::class,
  69.             'sonata_type_choice_field_mask' => ChoiceFieldMaskType::class,
  70.             'sonata_type_filter_number' => NumberType::class,
  71.             'sonata_type_filter_choice' => ChoiceType::class,
  72.             'sonata_type_filter_default' => DefaultType::class,
  73.             'sonata_type_filter_date' => DateType::class,
  74.             'sonata_type_filter_date_range' => DateRangeType::class,
  75.             'sonata_type_filter_datetime' => DateTimeType::class,
  76.             'sonata_type_filter_datetime_range' => DateTimeRangeType::class,
  77.             'tab' => TabType::class,
  78.         ]);
  79.         FormHelper::registerFormExtensionMapping('form', [
  80.             'sonata.admin.form.extension.field',
  81.             'mopa_bootstrap.form.type_extension.help',
  82.             'mopa_bootstrap.form.type_extension.legend',
  83.             'mopa_bootstrap.form.type_extension.error',
  84.             'mopa_bootstrap.form.type_extension.widget',
  85.             'mopa_bootstrap.form.type_extension.horizontal',
  86.             'mopa_bootstrap.form.type_extension.widget_collection',
  87.             'mopa_bootstrap.form.type_extension.tabbed',
  88.         ]);
  89.         FormHelper::registerFormExtensionMapping('choice', [
  90.             'sonata.admin.form.extension.choice',
  91.         ]);
  92.         FormHelper::registerFormExtensionMapping('button', [
  93.             'mopa_bootstrap.form.type_extension.button',
  94.         ]);
  95.         FormHelper::registerFormExtensionMapping('date', [
  96.             'mopa_bootstrap.form.type_extension.date',
  97.         ]);
  98.     }
  99. }