diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 21a29b1..1991328 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -8,10 +8,7 @@ class Configuration implements ConfigurationInterface { - /** - * @return TreeBuilder - */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('graphqlite'); $rootNode = $treeBuilder->getRootNode(); diff --git a/GraphQLiteBundle.php b/GraphQLiteBundle.php index 3de2289..b9005ab 100644 --- a/GraphQLiteBundle.php +++ b/GraphQLiteBundle.php @@ -21,9 +21,9 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new OverblogGraphiQLEndpointWiringPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1); } - public function getContainerExtension(): ?ExtensionInterface + public function getContainerExtension(): ExtensionInterface { - if (null === $this->extension) { + if (null === $this->extension || false === $this->extension) { $this->extension = new GraphQLiteExtension(); } diff --git a/Tests/GraphQLiteTestingKernel.php b/Tests/GraphQLiteTestingKernel.php index 5939922..5ec06d1 100644 --- a/Tests/GraphQLiteTestingKernel.php +++ b/Tests/GraphQLiteTestingKernel.php @@ -4,6 +4,8 @@ namespace TheCodingMachine\GraphQLite\Bundle\Tests; +use Composer\InstalledVersions; +use Composer\Semver\VersionParser; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\SecurityBundle\SecurityBundle; @@ -87,7 +89,7 @@ public function __construct(bool $enableSession = true, public function registerBundles(): iterable { $bundles = [ new FrameworkBundle() ]; - if (class_exists(SecurityBundle::class)) { + if ($this->enableSecurity && class_exists(SecurityBundle::class)) { $bundles[] = new SecurityBundle(); } $bundles[] = new GraphQLiteBundle(); @@ -118,8 +120,12 @@ public function configureContainer(ContainerBuilder $c, LoaderInterface $loader) $container->loadFromExtension('framework', $frameworkConf); if ($this->enableSecurity) { - $container->loadFromExtension('security', array( - 'enable_authenticator_manager' => true, + $extraConfig = []; + if (InstalledVersions::satisfies(new VersionParser(), 'symfony/security-bundle', '< 7.0.0')) { + $extraConfig['enable_authenticator_manager'] = true; + } + + $container->loadFromExtension('security', array_merge(array( 'providers' => [ 'in_memory' => [ 'memory' => [ @@ -150,7 +156,7 @@ public function configureContainer(ContainerBuilder $c, LoaderInterface $loader) 'password_hashers' => [ InMemoryUser::class => 'plaintext', ], - )); + ), $extraConfig)); } $graphqliteConf = array( diff --git a/composer.json b/composer.json index 5e47330..9251be4 100644 --- a/composer.json +++ b/composer.json @@ -20,25 +20,27 @@ "ext-json": "*", "thecodingmachine/graphqlite" : "^6.0", "thecodingmachine/graphqlite-symfony-validator-bridge" : "^6.0", - "symfony/framework-bundle": "^6", - "symfony/validator": "^6", - "symfony/translation": "^6", + "symfony/config": "^6.4 || ^7", + "symfony/console": "^6.4 || ^7", + "symfony/framework-bundle": "^6.4 || ^7", + "symfony/validator": "^6.4 || ^7", + "symfony/translation": "^6.4 || ^7", "doctrine/annotations": "^1.13 || ^2.0.1", - "symfony/psr-http-message-bridge": "^2.0", + "symfony/psr-http-message-bridge": "^2.0 || ^7.0", "nyholm/psr7": "^1.1", "laminas/laminas-diactoros": "^2.2.2", - "overblog/graphiql-bundle": "^0.2 || ^0.3", - "thecodingmachine/cache-utils": "^1", - "symfony/console": "^6" + "overblog/graphiql-bundle": "^0.2 || ^0.3 || ^1", + "thecodingmachine/cache-utils": "^1" }, "require-dev": { - "symfony/security-bundle": "^6", - "symfony/yaml": "^6", + "symfony/security-bundle": "^6.4 || ^7", + "symfony/yaml": "^6.4 || ^7", "beberlei/porpaginas": "^1.2 || ^2.0", "php-coveralls/php-coveralls": "^2.1.0", - "symfony/phpunit-bridge": "^6 || ^7", + "symfony/phpunit-bridge": "^6.4 || ^7", "phpstan/phpstan": "^1.8", - "composer/package-versions-deprecated": "^1.8" + "composer/package-versions-deprecated": "^1.8", + "composer/semver": "^3.4" }, "conflict": { "mouf/classname-mapper": "<1.0.2",