|
13 | 13 | namespace Omines\AntiSpamQuarantineBundle\DependencyInjection;
|
14 | 14 |
|
15 | 15 | use Omines\AntiSpamQuarantineBundle\AntiSpamQuarantineBundle;
|
| 16 | +use Symfony\Component\Config\FileLocator; |
16 | 17 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 | 18 | use Symfony\Component\DependencyInjection\Extension\Extension;
|
| 19 | +use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
| 20 | +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
18 | 21 |
|
19 |
| -class QuarantineExtension extends Extension |
| 22 | +class QuarantineExtension extends Extension implements PrependExtensionInterface |
20 | 23 | {
|
21 | 24 | public function load(array $configs, ContainerBuilder $container): void
|
22 | 25 | {
|
23 |
| - // TODO: Implement load() method. |
| 26 | + $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config')); |
| 27 | + $loader->load('services.yaml'); |
| 28 | + } |
| 29 | + |
| 30 | + public function prepend(ContainerBuilder $container): void |
| 31 | + { |
| 32 | + if ($container->hasExtension('doctrine')) { |
| 33 | + $container->prependExtensionConfig('doctrine', [ |
| 34 | + 'orm' => [ |
| 35 | + 'mappings' => [ |
| 36 | + 'QuarantineBundle' => [ |
| 37 | + 'type' => 'attribute', |
| 38 | + 'dir' => __DIR__ . '/../Entity', |
| 39 | + 'prefix' => 'Omines\AntiSpamQuarantineBundle\Entity', |
| 40 | + 'alias' => 'Quarantine', |
| 41 | + ], |
| 42 | + ], |
| 43 | + ], |
| 44 | + ]); |
| 45 | + } else { |
| 46 | + throw new \LogicException('DoctrineBundle is required for quarantine bundle to work, please run composer require doctrine/doctrine-bundle'); |
| 47 | + } |
24 | 48 | }
|
25 | 49 |
|
26 | 50 | public function getAlias(): string
|
|
0 commit comments