Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"php": "^8.0",
"symfony/http-foundation": "^5.4 || ^6.0 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/routing": "^5.4 || ^6.0 || ^7.00"
"symfony/routing": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"overblog/graphql-bundle": "dev-master",
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/OverblogGraphiQLExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;

class OverblogGraphiQLExtension extends Extension
Expand All @@ -20,8 +20,8 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.php');

$container->setParameter('overblog_graphiql.endpoint_resolver', $config['endpoint_resolver']);

Expand Down
24 changes: 24 additions & 0 deletions src/Resources/config/routing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Loader\XmlFileLoader;

return function (RoutingConfigurator $routes): void {
foreach (debug_backtrace() as $trace) {
if (isset($trace['object']) && $trace['object'] instanceof XmlFileLoader && 'doImport' === $trace['function']) {
if (__DIR__ === dirname(realpath($trace['args'][3]))) {
trigger_deprecation('symfony/routing', '7.3', 'The "routing.xml" routing configuration file is deprecated, import "routing.php" instead.');

break;
}
}
}

$routes->add('overblog_graphiql_endpoint', '/graphiql')
->controller('overblog_graphiql.controller::indexAction')
;

$routes->add('overblog_graphiql_endpoint_multiple', '/graphiql/{schemaName}')
->controller('overblog_graphiql.controller::indexAction')
;
};
36 changes: 36 additions & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
$services = $container->services();

$services->set('overblog_graphiql.controller.graphql.endpoint', \Overblog\GraphiQLBundle\Config\GraphiQLControllerEndpoint::class)
->private()
->autowire(false)
;

$services->set('overblog_graphiql.view.config', \Overblog\GraphiQLBundle\Config\GraphiQLViewConfig::class)
->private()
->autowire(false)
;

$services->set('overblog_graphiql.view.config.javascript_libraries', \Overblog\GraphiQLBundle\Config\GraphiQLViewJavaScriptLibraries::class)
->private()
->autowire(false)
;

$services->set('overblog_graphiql.controller', \Overblog\GraphiQLBundle\Controller\GraphiQLController::class)
->public()
->autowire(false)
->args([
service('twig'),
service('overblog_graphiql.view.config'),
service('overblog_graphiql.controller.graphql.endpoint'),
])
;

$services->alias(\Overblog\GraphiQLBundle\Controller\GraphiQLController::class, 'overblog_graphiql.controller')
->public()
;
};
2 changes: 1 addition & 1 deletion tests/Fixtures/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
'secret' => 'test',
'test' => true,
'assets' => ['enabled' => false],
'router' => ['resource' => '%kernel.project_dir%/src/Resources/config/routing.xml'],
'router' => ['resource' => '%kernel.project_dir%/src/Resources/config/routing.php'],
]);
});
}
Expand Down
37 changes: 37 additions & 0 deletions tests/Functional/DependencyInjection/Fixtures/Php/TestKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Fixtures\Php;

use Overblog\GraphiQLBundle\OverblogGraphiQLBundle;
use Overblog\GraphiQLBundle\Tests\TestKernel as AbstractTestKernel;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class TestKernel extends AbstractTestKernel
{
public function registerBundles(): array
{
return [
new FrameworkBundle(),
new TwigBundle(),
new OverblogGraphiQLBundle(),
];
}

/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config.php');
$loader->load(function (ContainerBuilder $container): void {
$container->loadFromExtension('framework', [
'assets' => ['enabled' => false],
]);
});
}
}
15 changes: 15 additions & 0 deletions tests/Functional/DependencyInjection/Fixtures/Php/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container): void {
$container->extension('framework', [
'test' => null,
'secret' => 'test',
'router' => [
'resource' => '%kernel.project_dir%/Resources/config/routing.xml',
],
'profiler' => ['enabled' => false],
'assets' => ['enabled' => false],
]);
};
29 changes: 29 additions & 0 deletions tests/Functional/DependencyInjection/Php/ConfigurationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Php;

use Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Fixtures\Php\TestKernel;
use Overblog\GraphiQLBundle\Tests\TestCase;

final class ConfigurationTest extends TestCase
{
protected static function getKernelClass(): string
{
return TestKernel::class;
}

public function setUp(): void
{
static::bootKernel(['test_case' => str_replace('\\', '_', __NAMESPACE__)]);
}

public function testSuccessConfiguration(): void
{
/** @var TestKernel $kernel */
$kernel = static::$kernel;

$this->assertTrue($kernel->isBooted());
}
}