SonataAdminBundle.php 3.8 KB

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