vendor/trikoder/oauth2-bundle/TrikoderOAuth2Bundle.php line 24

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Trikoder\Bundle\OAuth2Bundle;
  4. use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
  5. use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
  6. use Symfony\Component\DependencyInjection\ContainerBuilder;
  7. use Symfony\Component\HttpKernel\Bundle\Bundle;
  8. use Trikoder\Bundle\OAuth2Bundle\DependencyInjection\Security\OAuth2Factory;
  9. use Trikoder\Bundle\OAuth2Bundle\DependencyInjection\TrikoderOAuth2Extension;
  10. final class TrikoderOAuth2Bundle extends Bundle
  11. {
  12.     /**
  13.      * {@inheritdoc}
  14.      */
  15.     public function build(ContainerBuilder $container)
  16.     {
  17.         parent::build($container);
  18.         $this->configureDoctrineExtension($container);
  19.         $this->configureSecurityExtension($container);
  20.     }
  21.     /**
  22.      * {@inheritdoc}
  23.      */
  24.     public function getContainerExtension()
  25.     {
  26.         return new TrikoderOAuth2Extension();
  27.     }
  28.     private function configureSecurityExtension(ContainerBuilder $container): void
  29.     {
  30.         /** @var SecurityExtension $extension */
  31.         $extension $container->getExtension('security');
  32.         $extension->addSecurityListenerFactory(new OAuth2Factory());
  33.     }
  34.     private function configureDoctrineExtension(ContainerBuilder $container): void
  35.     {
  36.         $container->addCompilerPass(
  37.             DoctrineOrmMappingsPass::createXmlMappingDriver(
  38.                 [
  39.                     realpath(__DIR__ '/Resources/config/doctrine/model') => 'Trikoder\Bundle\OAuth2Bundle\Model',
  40.                 ],
  41.                 [
  42.                     'trikoder.oauth2.persistence.doctrine.manager',
  43.                 ],
  44.                 'trikoder.oauth2.persistence.doctrine.enabled',
  45.                 [
  46.                     'TrikoderOAuth2Bundle' => 'Trikoder\Bundle\OAuth2Bundle\Model',
  47.                 ]
  48.             )
  49.         );
  50.     }
  51. }