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

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