|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Sonata Project package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Sonata\MediaBundle; |
|
15
|
|
|
|
|
16
|
|
|
use Sonata\CoreBundle\Form\FormHelper; |
|
17
|
|
|
use Sonata\MediaBundle\DependencyInjection\Compiler\AddProviderCompilerPass; |
|
18
|
|
|
use Sonata\MediaBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass; |
|
19
|
|
|
use Sonata\MediaBundle\DependencyInjection\Compiler\ThumbnailCompilerPass; |
|
20
|
|
|
use Sonata\MediaBundle\DependencyInjection\Compiler\TwigStringExtensionCompilerPass; |
|
21
|
|
|
use Sonata\MediaBundle\Form\Type\ApiDoctrineMediaType; |
|
22
|
|
|
use Sonata\MediaBundle\Form\Type\ApiGalleryItemType; |
|
23
|
|
|
use Sonata\MediaBundle\Form\Type\ApiGalleryType; |
|
24
|
|
|
use Sonata\MediaBundle\Form\Type\ApiMediaType; |
|
25
|
|
|
use Sonata\MediaBundle\Form\Type\MediaType; |
|
26
|
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
|
27
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
28
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @final since sonata-project/media-bundle 3.21.0 |
|
32
|
|
|
*/ |
|
33
|
|
|
class SonataMediaBundle extends Bundle |
|
34
|
|
|
{ |
|
35
|
|
|
public function build(ContainerBuilder $container): void |
|
36
|
|
|
{ |
|
37
|
|
|
$container->addCompilerPass(new AddProviderCompilerPass()); |
|
38
|
|
|
$container->addCompilerPass(new GlobalVariablesCompilerPass()); |
|
39
|
|
|
$container->addCompilerPass(new ThumbnailCompilerPass()); |
|
40
|
|
|
$container->addCompilerPass(new TwigStringExtensionCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1); |
|
41
|
|
|
|
|
42
|
|
|
$this->registerFormMapping(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function boot(): void |
|
46
|
|
|
{ |
|
47
|
|
|
// this is required by the AWS SDK (see: https://github.com/knplabs/Gaufrette) |
|
48
|
|
|
if (!\defined('AWS_CERTIFICATE_AUTHORITY')) { |
|
49
|
|
|
\define('AWS_CERTIFICATE_AUTHORITY', true); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$this->registerFormMapping(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Register form mapping information. |
|
57
|
|
|
* |
|
58
|
|
|
* NEXT_MAJOR: remove this method |
|
59
|
|
|
*/ |
|
60
|
|
|
public function registerFormMapping(): void |
|
61
|
|
|
{ |
|
62
|
|
|
if (class_exists(FormHelper::class)) { |
|
63
|
|
|
FormHelper::registerFormTypeMapping([ |
|
64
|
|
|
'sonata_media_type' => MediaType::class, |
|
65
|
|
|
'sonata_media_api_form_media' => ApiMediaType::class, |
|
66
|
|
|
'sonata_media_api_form_doctrine_media' => ApiDoctrineMediaType::class, |
|
67
|
|
|
'sonata_media_api_form_gallery' => ApiGalleryType::class, |
|
68
|
|
|
'sonata_media_api_form_gallery_item' => ApiGalleryItemType::class, |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|