Skip to content

Commit 565fa29

Browse files
authored
Merge pull request #6 from moufmouf/first_run
The bundle should not trigger exceptions if no config is set
2 parents cd2b446 + f2410d0 commit 565fa29

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class Configuration implements ConfigurationInterface
1010
{
1111
public function getConfigTreeBuilder()
1212
{
13-
$treeBuilder = new TreeBuilder();
14-
$rootNode = $treeBuilder->root('graphqlite');
13+
$treeBuilder = new TreeBuilder('graphqlite');
14+
$rootNode = $treeBuilder->getRootNode();
1515

1616
$rootNode
1717
->children()
1818
//->scalarNode('controllers_namespace')->defaultValue('App\\Controllers')->end()
1919
//->scalarNode('types_namespace')->defaultValue('App\\Types')->end()
20-
->arrayNode('namespace')->isRequired()
20+
->arrayNode('namespace')/*->isRequired()*/
2121
->children()
2222
->arrayNode('controllers')
2323
->requiresAtLeastOneElement()

DependencyInjection/GraphqliteExtension.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
55

66

7+
use function array_map;
78
use GraphQL\Error\Debug;
89
use GraphQL\Server\ServerConfig;
910
use GraphQL\Type\Definition\ObjectType;
1011
use function implode;
1112
use function is_dir;
1213
use Mouf\Composer\ClassNameMapper;
14+
use function rtrim;
1315
use Symfony\Component\Config\FileLocator;
1416
use Symfony\Component\DependencyInjection\ContainerBuilder;
1517
use Symfony\Component\DependencyInjection\Definition;
@@ -34,8 +36,16 @@ public function load(array $configs, ContainerBuilder $container)
3436
//$config = $this->processConfiguration($this->getConfiguration($config, $container), $config);
3537
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/container'));
3638

37-
$namespaceController = array_map(function($namespace) { return rtrim($namespace, '\\') . '\\'; }, $config['namespace']['controllers']);
38-
$namespaceType = array_map(function($namespace) { return rtrim($namespace, '\\') . '\\'; }, $config['namespace']['types']);
39+
if (isset($configs[0]['namespace']['controllers'])) {
40+
$namespaceController = array_map(function($namespace) { return rtrim($namespace, '\\') . '\\'; }, $configs[0]['namespace']['controllers']);
41+
} else {
42+
$namespaceController = [];
43+
}
44+
if (isset($configs[0]['namespace']['types'])) {
45+
$namespaceType = array_map(function($namespace) { return rtrim($namespace, '\\') . '\\'; }, $configs[0]['namespace']['types']);
46+
} else {
47+
$namespaceType = [];
48+
}
3949

4050
$container->setParameter('graphqlite.namespace.controllers', $namespaceController);
4151
$container->setParameter('graphqlite.namespace.types', $namespaceType);

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"doctrine/annotations": "^1.6",
2323
"doctrine/cache": "^1.8",
2424
"symfony/psr-http-message-bridge": "^1",
25+
"nyholm/psr7": "^1.1",
2526
"zendframework/zend-diactoros": "^1.8.6",
2627
"overblog/graphiql-bundle": "^0.1.2"
2728
},

0 commit comments

Comments
 (0)