vendor/sonata-project/media-bundle/src/SonataMediaBundle.php line 31

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\MediaBundle;
  12. use Sonata\CoreBundle\Form\FormHelper;
  13. use Sonata\MediaBundle\DependencyInjection\Compiler\AddProviderCompilerPass;
  14. use Sonata\MediaBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass;
  15. use Sonata\MediaBundle\DependencyInjection\Compiler\ThumbnailCompilerPass;
  16. use Sonata\MediaBundle\Form\Type\ApiDoctrineMediaType;
  17. use Sonata\MediaBundle\Form\Type\ApiGalleryHasMediaType;
  18. use Sonata\MediaBundle\Form\Type\ApiGalleryType;
  19. use Sonata\MediaBundle\Form\Type\ApiMediaType;
  20. use Sonata\MediaBundle\Form\Type\MediaType;
  21. use Symfony\Component\DependencyInjection\ContainerBuilder;
  22. use Symfony\Component\HttpKernel\Bundle\Bundle;
  23. /**
  24.  * @final since sonata-project/media-bundle 3.21.0
  25.  */
  26. class SonataMediaBundle extends Bundle
  27. {
  28.     /**
  29.      * {@inheritdoc}
  30.      */
  31.     public function build(ContainerBuilder $container)
  32.     {
  33.         $container->addCompilerPass(new AddProviderCompilerPass());
  34.         $container->addCompilerPass(new GlobalVariablesCompilerPass());
  35.         $container->addCompilerPass(new ThumbnailCompilerPass());
  36.         $this->registerFormMapping();
  37.     }
  38.     /**
  39.      * {@inheritdoc}
  40.      */
  41.     public function boot()
  42.     {
  43.         // this is required by the AWS SDK (see: https://github.com/knplabs/Gaufrette)
  44.         if (!\defined('AWS_CERTIFICATE_AUTHORITY')) {
  45.             \define('AWS_CERTIFICATE_AUTHORITY'true);
  46.         }
  47.         $this->registerFormMapping();
  48.     }
  49.     /**
  50.      * Register form mapping information.
  51.      */
  52.     public function registerFormMapping()
  53.     {
  54.         FormHelper::registerFormTypeMapping([
  55.             'sonata_media_type' => MediaType::class,
  56.             'sonata_media_api_form_media' => ApiMediaType::class,
  57.             'sonata_media_api_form_doctrine_media' => ApiDoctrineMediaType::class,
  58.             'sonata_media_api_form_gallery' => ApiGalleryType::class,
  59.             'sonata_media_api_form_gallery_has_media' => ApiGalleryHasMediaType::class,
  60.         ]);
  61.     }
  62. }