Skip to content

Commit 4d1fb07

Browse files
author
Jeremiah VALERIE
committed
Accept yaml extension
1 parent 7d03b9a commit 4d1fb07

File tree

24 files changed

+33
-38
lines changed

24 files changed

+33
-38
lines changed

Config/Parser/YmlParser.php renamed to Config/Parser/YamlParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1717
use Symfony\Component\Finder\SplFileInfo;
1818
use Symfony\Component\Yaml\Exception\ParseException;
19-
use Symfony\Component\Yaml\Parser as YamlParser;
19+
use Symfony\Component\Yaml\Parser;
2020

21-
class YmlParser implements ParserInterface
21+
class YamlParser implements ParserInterface
2222
{
2323
private static $yamlParser;
2424

@@ -31,7 +31,7 @@ class YmlParser implements ParserInterface
3131
public static function parse(SplFileInfo $file, ContainerBuilder $container)
3232
{
3333
if (null === self::$yamlParser) {
34-
self::$yamlParser = new YamlParser();
34+
self::$yamlParser = new Parser();
3535
}
3636

3737
try {

DependencyInjection/Compiler/ConfigTypesPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function process(ContainerBuilder $container)
3636
$aliases = call_user_func($class.'::getAliases');
3737
$this->setTypeServiceDefinition($container, $class, $aliases);
3838
}
39+
$container->getParameterBag()->remove('overblog_graphql_types.config');
3940
}
4041

4142
private function setTypeServiceDefinition(ContainerBuilder $container, $class, array $aliases)

DependencyInjection/Compiler/MutationTaggedServiceMappingTaggedPass.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ protected function getTagName()
1818
return 'overblog_graphql.mutation';
1919
}
2020

21-
protected function getParameterName()
22-
{
23-
return 'overblog_graphql.mutations_mapping';
24-
}
25-
2621
protected function getResolverServiceID()
2722
{
2823
return 'overblog_graphql.mutation_resolver';

DependencyInjection/Compiler/ResolverTaggedServiceMappingPass.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ protected function getTagName()
1818
return 'overblog_graphql.resolver';
1919
}
2020

21-
protected function getParameterName()
22-
{
23-
return 'overblog_graphql.resolvers_mapping';
24-
}
25-
2621
protected function checkRequirements($id, array $tag)
2722
{
2823
parent::checkRequirements($id, $tag);

DependencyInjection/Compiler/TaggedServiceMappingPass.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ private function getTaggedServiceMapping(ContainerBuilder $container, $tagName)
5454
public function process(ContainerBuilder $container)
5555
{
5656
$mapping = $this->getTaggedServiceMapping($container, $this->getTagName());
57-
$container->setParameter($this->getParameterName(), $mapping);
5857
$resolverDefinition = $container->findDefinition($this->getResolverServiceID());
5958

6059
foreach ($mapping as $name => $options) {
@@ -101,6 +100,4 @@ protected function checkRequirements($id, array $tag)
101100
abstract protected function getTagName();
102101

103102
abstract protected function getResolverServiceID();
104-
105-
abstract protected function getParameterName();
106103
}

DependencyInjection/Compiler/TypeTaggedServiceMappingPass.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ protected function getTagName()
1818
return 'overblog_graphql.type';
1919
}
2020

21-
protected function getParameterName()
22-
{
23-
return 'overblog_graphql.types_mapping';
24-
}
25-
2621
protected function getResolverServiceID()
2722
{
2823
return 'overblog_graphql.type_resolver';

DependencyInjection/Configuration.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,18 @@ public function getConfigTreeBuilder()
9898
->arrayNode('types')
9999
->prototype('array')
100100
->addDefaultsIfNotSet()
101+
->beforeNormalization()
102+
->ifTrue(function ($v) {
103+
return isset($v['type']) && $v['type'] === 'yml';
104+
})
105+
->then(function ($v) {
106+
$v['type'] = 'yaml';
107+
108+
return $v;
109+
})
110+
->end()
101111
->children()
102-
->enumNode('type')->isRequired()->values(['yml', 'xml'])->end()
112+
->enumNode('type')->isRequired()->values(['yaml', 'xml'])->end()
103113
->scalarNode('dir')->defaultNull()->end()
104114
->end()
105115
->end()

DependencyInjection/OverblogGraphQLTypesExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
class OverblogGraphQLTypesExtension extends Extension
2121
{
22-
private static $configTypes = ['yml', 'xml'];
22+
private static $configTypes = ['yaml', 'xml'];
23+
24+
private static $typeExtensions = ['yaml' => '{yaml,yml}', 'xml' => 'xml'];
2325

2426
public function load(array $configs, ContainerBuilder $container)
2527
{
@@ -112,7 +114,7 @@ private function detectFilesByType(ContainerBuilder $container, $path, $type = n
112114

113115
foreach ($types as $type) {
114116
try {
115-
$finder->files()->in($path)->name('*.types.'.$type);
117+
$finder->files()->in($path)->name('*.types.'.self::$typeExtensions[$type]);
116118
} catch (\InvalidArgumentException $e) {
117119
continue;
118120
}

Resources/doc/definitions/type-system/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Types can be define 3 different ways:
2727
mappings:
2828
types:
2929
-
30-
type: yml # or xml
30+
type: yaml # or xml
3131
dir: "%kernel.root_dir%/.../mapping"
3232
```
3333

Tests/DependencyInjection/OverblogGraphQLTypesExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testDuplicatedType()
6161
*/
6262
public function testBrokenYmlOnPrepend()
6363
{
64-
$this->extension->containerPrependExtensionConfig($this->getBrokenMappingConfig('yml'), $this->container);
64+
$this->extension->containerPrependExtensionConfig($this->getBrokenMappingConfig('yaml'), $this->container);
6565
}
6666

6767
/**

0 commit comments

Comments
 (0)