|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Silverback API Components Bundle Project |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Daniel West <[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
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Silverback\ApiComponentsBundle; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; |
|
17
|
|
|
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\ApiPlatformCompilerPass; |
|
18
|
|
|
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\DoctrineOrmCompilerPass; |
|
19
|
|
|
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\FlysystemCompilerPass; |
|
20
|
|
|
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\ImagineCompilerPass; |
|
21
|
|
|
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\SerializerCompilerPass; |
|
22
|
|
|
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\ValidatorCompilerPass; |
|
23
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
24
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @author Daniel West <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
class SilverbackApiComponentsBundle extends Bundle |
|
30
|
|
|
{ |
|
31
|
|
|
public function build(ContainerBuilder $container): void |
|
32
|
|
|
{ |
|
33
|
|
|
parent::build($container); |
|
34
|
|
|
|
|
35
|
|
|
$container->addCompilerPass(new ApiPlatformCompilerPass()); |
|
36
|
|
|
$container->addCompilerPass(new SerializerCompilerPass()); |
|
37
|
|
|
$container->addCompilerPass(new ValidatorCompilerPass()); |
|
38
|
|
|
$container->addCompilerPass(new FlysystemCompilerPass()); |
|
39
|
|
|
|
|
40
|
|
|
if (class_exists(DoctrineOrmMappingsPass::class)) { |
|
41
|
|
|
$container->addCompilerPass(new DoctrineOrmCompilerPass()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$bundles = $container->getParameter('kernel.bundles'); |
|
45
|
|
|
$imagineEnabled = isset($bundles['LiipImagineBundle']); |
|
46
|
|
|
$container->setParameter('api_components.imagine_enabled', $imagineEnabled); |
|
47
|
|
|
if ($imagineEnabled) { |
|
48
|
|
|
$container->addCompilerPass(new ImagineCompilerPass()); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|