vendor/web-token/jwt-framework/src/Bundle/JoseFramework/JoseFrameworkBundle.php line 25

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * The MIT License (MIT)
  5.  *
  6.  * Copyright (c) 2014-2020 Spomky-Labs
  7.  *
  8.  * This software may be modified and distributed under the terms
  9.  * of the MIT license.  See the LICENSE file for details.
  10.  */
  11. namespace Jose\Bundle\JoseFramework;
  12. use Jose\Bundle\JoseFramework\DependencyInjection\Compiler\EventDispatcherAliasCompilerPass;
  13. use Jose\Bundle\JoseFramework\DependencyInjection\Compiler\SymfonySerializerCompilerPass;
  14. use Jose\Bundle\JoseFramework\DependencyInjection\JoseFrameworkExtension;
  15. use Jose\Bundle\JoseFramework\DependencyInjection\Source;
  16. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  17. use Symfony\Component\DependencyInjection\ContainerBuilder;
  18. use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  19. use Symfony\Component\HttpKernel\Bundle\Bundle;
  20. final class JoseFrameworkBundle extends Bundle
  21. {
  22.     /**
  23.      * @var Source\Source[]
  24.      */
  25.     private $sources = [];
  26.     public function __construct()
  27.     {
  28.         foreach ($this->getSources() as $source) {
  29.             $this->sources[$source->name()] = $source;
  30.         }
  31.     }
  32.     public function getContainerExtension(): ExtensionInterface
  33.     {
  34.         return new JoseFrameworkExtension('jose'$this->sources);
  35.     }
  36.     public function build(ContainerBuilder $container): void
  37.     {
  38.         parent::build($container);
  39.         foreach ($this->sources as $source) {
  40.             if ($source instanceof Source\SourceWithCompilerPasses) {
  41.                 $compilerPasses $source->getCompilerPasses();
  42.                 foreach ($compilerPasses as $compilerPass) {
  43.                     $container->addCompilerPass($compilerPass);
  44.                 }
  45.             }
  46.         }
  47.         $container->addCompilerPass(new EventDispatcherAliasCompilerPass());
  48.         $container->addCompilerPass(new SymfonySerializerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION10);
  49.     }
  50.     /**
  51.      * @return Source\Source[]
  52.      */
  53.     private function getSources(): iterable
  54.     {
  55.         return [
  56.             new Source\Core\CoreSource(),
  57.             new Source\Checker\CheckerSource(),
  58.             new Source\Console\ConsoleSource(),
  59.             new Source\Signature\SignatureSource(),
  60.             new Source\Encryption\EncryptionSource(),
  61.             new Source\NestedToken\NestedToken(),
  62.             new Source\KeyManagement\KeyManagementSource(),
  63.         ];
  64.     }
  65. }