vendor/specshaper/encrypt-bundle/src/DependencyInjection/SpecShaperEncryptExtension.php line 20

Open in your IDE?
  1. <?php
  2. namespace SpecShaper\EncryptBundle\DependencyInjection;
  3. use SpecShaper\EncryptBundle\Subscribers\DoctrineEncryptSubscriber;
  4. use SpecShaper\EncryptBundle\Subscribers\EncryptEventSubscriber;
  5. use Symfony\Component\Config\FileLocator;
  6. use Symfony\Component\DependencyInjection\ContainerBuilder;
  7. use Symfony\Component\DependencyInjection\Definition;
  8. use Symfony\Component\DependencyInjection\Loader;
  9. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  10. /**
  11.  * This is the class that loads and manages your bundle configuration.
  12.  *
  13.  * @see http://symfony.com/doc/current/cookbook/bundles/extension.html
  14.  */
  15. class SpecShaperEncryptExtension extends Extension
  16. {
  17.     public function load(array $configsContainerBuilder $container)
  18.     {
  19.         $configuration = new Configuration();
  20.         $config $this->processConfiguration($configuration$configs);
  21.         $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
  22.         $loader->load('services.yaml');
  23.         if ($container->hasParameter('encrypt_key')) {
  24.             trigger_deprecation('SpecShaperEncryptBundle''v3.0.2''storing Specshaper Encrypt Key in parameters is deprecated. Move to Config/Packages/spec_shaper_encrypt.yaml');
  25.             $encryptKey $container->getParameter('encrypt_key');
  26.         } else {
  27.             $encryptKey $config['encrypt_key'];
  28.         }
  29. //
  30. //        dump($encryptKey);
  31.         if (array_key_exists('subscriber_class'$config)) {
  32.             trigger_deprecation('SpecShaperEncryptBundle''v4.0.0''DoctrineSubscribers will be deprecated in version 4. If you
  33.             have a custom subscriber in the encrypt bundle then this will need to be changed to a DoctrineListener.');
  34.         }
  35.         $container->setParameter($this->getAlias().'.encrypt_key'$encryptKey);
  36.         $container->setParameter($this->getAlias().'.default_associated_data'$config['default_associated_data']);
  37.         $container->setParameter($this->getAlias().'.method'$config['method']);
  38.         $container->setParameter($this->getAlias().'.subscriber_class'$config['subscriber_class']);
  39.         $container->setParameter($this->getAlias().'.encryptor_class'$config['encryptor_class']);
  40.         $container->setParameter($this->getAlias().'.annotation_classes'$config['annotation_classes']);
  41.         $container->setParameter($this->getAlias().'.is_disabled'$config['is_disabled']);
  42.         $doctrineSubscriber = new Definition($config['subscriber_class']);
  43.         $doctrineSubscriber
  44.             ->setAutowired(true)
  45.             ->setArgument(3$config['annotation_classes'])
  46.             ->setArgument(4$config['is_disabled'])
  47.         ;
  48.         $encryptEventSubscriber = new Definition(EncryptEventSubscriber::class);
  49.         $encryptEventSubscriber
  50.             ->setAutowired(true)
  51.             ->setArgument(1$config['is_disabled'])
  52.         ;
  53.         foreach ($config['connections'] as $connectionName) {
  54.             $doctrineSubscriber->addTag('doctrine.event_subscriber', [
  55.                 'priority' => 500,
  56.                 'connection' => $connectionName,
  57.             ]);
  58.             $encryptEventSubscriber->addTag('kernal.event_subscriber', [
  59.                 'connection' => $connectionName,
  60.             ]);
  61.         }
  62.         $container->addDefinitions([
  63.             DoctrineEncryptSubscriber::class => $doctrineSubscriber,
  64.             EncryptEventSubscriber::class => $encryptEventSubscriber
  65.         ]);
  66.         // Check if Twig is available
  67.         if ($config['enable_twig'] && class_exists(\Twig\Environment::class)) {
  68.             $loader->load('twig_services.yaml');
  69.         }
  70.     }
  71. }