vendor/league/oauth2-server-bundle/src/LeagueOAuth2ServerBundle.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace League\Bundle\OAuth2ServerBundle;
  4. use League\Bundle\OAuth2ServerBundle\DependencyInjection\CompilerPass\EncryptionKeyPass;
  5. use League\Bundle\OAuth2ServerBundle\DependencyInjection\CompilerPass\RegisterDoctrineOrmMappingPass;
  6. use League\Bundle\OAuth2ServerBundle\DependencyInjection\LeagueOAuth2ServerExtension;
  7. use League\Bundle\OAuth2ServerBundle\DependencyInjection\Security\OAuth2Factory;
  8. use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
  9. use Symfony\Component\DependencyInjection\ContainerBuilder;
  10. use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  11. use Symfony\Component\HttpKernel\Bundle\Bundle;
  12. final class LeagueOAuth2ServerBundle extends Bundle
  13. {
  14.     /**
  15.      * {@inheritdoc}
  16.      *
  17.      * @return void
  18.      */
  19.     public function build(ContainerBuilder $container)
  20.     {
  21.         parent::build($container);
  22.         $this->configureDoctrineExtension($container);
  23.         $this->configureSecurityExtension($container);
  24.     }
  25.     /**
  26.      * {@inheritdoc}
  27.      */
  28.     public function getContainerExtension(): ExtensionInterface
  29.     {
  30.         return new LeagueOAuth2ServerExtension();
  31.     }
  32.     private function configureSecurityExtension(ContainerBuilder $container): void
  33.     {
  34.         /** @var SecurityExtension $extension */
  35.         $extension $container->getExtension('security');
  36.         if (method_exists($extension'addAuthenticatorFactory')) {
  37.             $extension->addAuthenticatorFactory(new OAuth2Factory());
  38.             return;
  39.         }
  40.         /**
  41.          * @psalm-suppress DeprecatedMethod
  42.          * @psalm-suppress InvalidArgument
  43.          */
  44.         $extension->addSecurityListenerFactory(new OAuth2Factory());
  45.     }
  46.     private function configureDoctrineExtension(ContainerBuilder $container): void
  47.     {
  48.         $container->addCompilerPass(new RegisterDoctrineOrmMappingPass());
  49.         $container->addCompilerPass(new EncryptionKeyPass());
  50.     }
  51. }