@@ -19,16 +19,16 @@ |
||
19 | 19 | { |
20 | 20 | public function process(ContainerBuilder $container) |
21 | 21 | { |
22 | - $extensions = []; |
|
22 | + $extensions = [ ]; |
|
23 | 23 | foreach ($container->findTaggedServiceIds('webuni_commonmark.extension') as $id => $tag) { |
24 | - $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $id; |
|
25 | - $extensions[$alias] = $id; |
|
24 | + $alias = isset($tag[ 0 ][ 'alias' ]) ? $tag[ 0 ][ 'alias' ] : $id; |
|
25 | + $extensions[ $alias ] = $id; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | if ($container->hasDefinition('webuni_commonmark.default_environment')) { |
29 | 29 | $definition = $container->getDefinition('webuni_commonmark.default_environment'); |
30 | 30 | foreach ($extensions as $alias => $id) { |
31 | - $definition->addMethodCall('addExtension', [new Reference($id)]); |
|
31 | + $definition->addMethodCall('addExtension', [ new Reference($id) ]); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | ->end() |
33 | 33 | ->end() |
34 | 34 | ->arrayNode('converters') |
35 | - ->defaultValue(['default' => [ |
|
35 | + ->defaultValue([ 'default' => [ |
|
36 | 36 | 'converter' => 'webuni_commonmark.converter', |
37 | 37 | 'environment' => 'webuni_commonmark.default_environment', |
38 | 38 | 'parser' => 'webuni_commonmark.docparser', |
39 | 39 | 'renderer' => 'webuni_commonmark.htmlrenderer', |
40 | - 'config' => [], |
|
41 | - 'extensions' => [], |
|
42 | - ]]) |
|
40 | + 'config' => [ ], |
|
41 | + 'extensions' => [ ], |
|
42 | + ] ]) |
|
43 | 43 | ->beforeNormalization() |
44 | 44 | ->always() |
45 | - ->then(function ($v) { |
|
46 | - return array_merge(['default' => null], $v); |
|
45 | + ->then(function($v) { |
|
46 | + return array_merge([ 'default' => null ], $v); |
|
47 | 47 | }) |
48 | 48 | ->end() |
49 | 49 | ->prototype('array') |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | ->scalarNode('renderer')->defaultValue('webuni_commonmark.htmlrenderer')->end() |
56 | 56 | ->arrayNode('config') |
57 | 57 | ->prototype('variable') |
58 | - ->defaultValue([]) |
|
58 | + ->defaultValue([ ]) |
|
59 | 59 | ->end() |
60 | 60 | ->end() |
61 | 61 | ->arrayNode('extensions') |
62 | - ->defaultValue([]) |
|
62 | + ->defaultValue([ ]) |
|
63 | 63 | ->prototype('scalar')->end() |
64 | 64 | ->end() |
65 | 65 | ->end() |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
26 | 26 | $loader->load('services.xml'); |
27 | 27 | |
28 | - if ($mergedConfig['extensions']['attributes'] && class_exists('Webuni\CommonMark\AttributesExtension\AttributesExtension')) { |
|
28 | + if ($mergedConfig[ 'extensions' ][ 'attributes' ] && class_exists('Webuni\CommonMark\AttributesExtension\AttributesExtension')) { |
|
29 | 29 | $loader->load('extensions/attributes.xml'); |
30 | 30 | } |
31 | 31 | |
32 | - if ($mergedConfig['extensions']['table'] && class_exists('Webuni\CommonMark\TableExtension\TableExtension')) { |
|
32 | + if ($mergedConfig[ 'extensions' ][ 'table' ] && class_exists('Webuni\CommonMark\TableExtension\TableExtension')) { |
|
33 | 33 | $loader->load('extensions/table.xml'); |
34 | 34 | } |
35 | 35 | |
36 | - $converters = []; |
|
37 | - foreach ($mergedConfig['converters'] as $name => $config) { |
|
38 | - $converters[$name] = new Reference($this->createConverter($name, $config, $container)); |
|
36 | + $converters = [ ]; |
|
37 | + foreach ($mergedConfig[ 'converters' ] as $name => $config) { |
|
38 | + $converters[ $name ] = new Reference($this->createConverter($name, $config, $container)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $registry = $container->getDefinition('webuni_commonmark.converter_registry'); |
@@ -49,29 +49,29 @@ discard block |
||
49 | 49 | |
50 | 50 | private function createConverter($name, array $config, ContainerBuilder $container) |
51 | 51 | { |
52 | - $environment = new DefinitionDecorator($config['environment']); |
|
52 | + $environment = new DefinitionDecorator($config[ 'environment' ]); |
|
53 | 53 | $environment->setPublic(false); |
54 | - $environment->setClass($container->getDefinition($config['environment'])->getClass()); |
|
55 | - $environment->addMethodCall('mergeConfig', [$config['config']]); |
|
56 | - $environment->addTag('webuni_commonmark.environment.extensions', $config['extensions']); |
|
54 | + $environment->setClass($container->getDefinition($config[ 'environment' ])->getClass()); |
|
55 | + $environment->addMethodCall('mergeConfig', [ $config[ 'config' ] ]); |
|
56 | + $environment->addTag('webuni_commonmark.environment.extensions', $config[ 'extensions' ]); |
|
57 | 57 | // $environment->addTag('webuni_commonmark.environment', ['parent' => $config['environment'], 'extensions' => [$config['extensions']]); |
58 | 58 | |
59 | - $environmentName = 'webuni_commonmark.'.$name.'_environment'.$config['environment']; |
|
59 | + $environmentName = 'webuni_commonmark.'.$name.'_environment'.$config[ 'environment' ]; |
|
60 | 60 | $container->setDefinition($environmentName, $environment); |
61 | 61 | |
62 | - $parser = new DefinitionDecorator($config['parser']); |
|
62 | + $parser = new DefinitionDecorator($config[ 'parser' ]); |
|
63 | 63 | $parser->setPublic(false); |
64 | - $parser->setClass($container->getDefinition($config['parser'])->getClass()); |
|
64 | + $parser->setClass($container->getDefinition($config[ 'parser' ])->getClass()); |
|
65 | 65 | $parser->replaceArgument(0, new Reference($environmentName)); |
66 | 66 | |
67 | - $renderer = new DefinitionDecorator($config['renderer']); |
|
67 | + $renderer = new DefinitionDecorator($config[ 'renderer' ]); |
|
68 | 68 | $renderer->setPublic(false); |
69 | - $renderer->setClass($container->getDefinition($config['renderer'])->getClass()); |
|
69 | + $renderer->setClass($container->getDefinition($config[ 'renderer' ])->getClass()); |
|
70 | 70 | $renderer->replaceArgument(0, new Reference($environmentName)); |
71 | 71 | |
72 | - $converter = new DefinitionDecorator($config['converter']); |
|
72 | + $converter = new DefinitionDecorator($config[ 'converter' ]); |
|
73 | 73 | $converter->setPublic(true); |
74 | - $converter->setClass($container->getDefinition($config['converter'])->getClass()); |
|
74 | + $converter->setClass($container->getDefinition($config[ 'converter' ])->getClass()); |
|
75 | 75 | $converter->replaceArgument(0, $parser); |
76 | 76 | $converter->replaceArgument(1, $renderer); |
77 | 77 |
@@ -20,18 +20,18 @@ |
||
20 | 20 | * |
21 | 21 | * @param Converter[] $converters |
22 | 22 | */ |
23 | - public function __construct(array $converters = []) |
|
23 | + public function __construct(array $converters = [ ]) |
|
24 | 24 | { |
25 | 25 | $this->converters = $converters; |
26 | 26 | } |
27 | 27 | |
28 | 28 | public function has($name) |
29 | 29 | { |
30 | - return isset($this->converters[$name]); |
|
30 | + return isset($this->converters[ $name ]); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function get($name) |
34 | 34 | { |
35 | - return $this->converters[$name]; |
|
35 | + return $this->converters[ $name ]; |
|
36 | 36 | } |
37 | 37 | } |