From 951f1fa8787c62219a9e6dbae432f1e8eb620ac2 Mon Sep 17 00:00:00 2001 From: Richard Miller Date: Mon, 24 Sep 2012 20:36:10 +0100 Subject: [PATCH 1/2] Fixing line length to avoid horizontal scrolling in DI component --- .../dependency_injection/compilation.rst | 25 +++++++++--- components/dependency_injection/tags.rst | 38 ++++++++++++++----- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/components/dependency_injection/compilation.rst b/components/dependency_injection/compilation.rst index 4993b0d233e..54363dc33ae 100644 --- a/components/dependency_injection/compilation.rst +++ b/components/dependency_injection/compilation.rst @@ -59,7 +59,10 @@ A very simple extension may just load configuration files into the container:: { public function load(array $configs, ContainerBuilder $container) { - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new XmlFileLoader( + $container, + new FileLocator(__DIR__.'/../Resources/config') + ); $loader->load('services.xml'); } @@ -223,7 +226,10 @@ but also load a secondary one only if a certain parameter is set:: $processor = new Processor(); $config = $processor->processConfiguration($configuration, $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new XmlFileLoader( + $container, + new FileLocator(__DIR__.'/../Resources/config') + ); $loader->load('services.xml'); if ($config['advanced']) { @@ -305,7 +311,10 @@ For example, to run your custom pass after the default removal passes have been use Symfony\Component\DependencyInjection\Compiler\PassConfig; $container = new ContainerBuilder(); - $container->addCompilerPass(new CustomCompilerPass, PassConfig::TYPE_AFTER_REMOVING); + $container->addCompilerPass( + new CustomCompilerPass, + PassConfig::TYPE_AFTER_REMOVING + ); Dumping the Configuration for Performance ----------------------------------------- @@ -351,7 +360,10 @@ it:: $container->compile(); $dumper = new PhpDumper($container); - file_put_contents($file, $dumper->dump(array('class' => 'MyCachedContainer'))); + file_put_contents( + $file, + $dumper->dump(array('class' => 'MyCachedContainer')) + ); } You will now get the speed of the PHP configured container with the ease of using @@ -380,7 +392,10 @@ but getting an up to date configuration whilst developing your application:: if (!$isDebug) { $dumper = new PhpDumper($container); - file_put_contents($file, $dumper->dump(array('class' => 'MyCachedContainer'))); + file_put_contents( + $file, + $dumper->dump(array('class' => 'MyCachedContainer')) + ); } } diff --git a/components/dependency_injection/tags.rst b/components/dependency_injection/tags.rst index f29f7fae0a1..e75169b896a 100644 --- a/components/dependency_injection/tags.rst +++ b/components/dependency_injection/tags.rst @@ -128,14 +128,24 @@ custom tag:: { public function process(ContainerBuilder $container) { - if (false === $container->hasDefinition('acme_mailer.transport_chain')) { + if (false === $container->hasDefinition( + 'acme_mailer.transport_chain' + )) { return; } - $definition = $container->getDefinition('acme_mailer.transport_chain'); - - foreach ($container->findTaggedServiceIds('acme_mailer.transport') as $id => $attributes) { - $definition->addMethodCall('addTransport', array(new Reference($id))); + $definition = $container->getDefinition( + 'acme_mailer.transport_chain' + ); + + $taggedServices = $container->findTaggedServiceIds( + 'acme_mailer.transport' + ); + foreach ($taggedServices as $id => $attributes) { + $definition->addMethodCall( + 'addTransport', + array(new Reference($id)) + ); } } } @@ -242,15 +252,25 @@ use this, update the compiler:: { public function process(ContainerBuilder $container) { - if (false === $container->hasDefinition('acme_mailer.transport_chain')) { + if (false === $container->hasDefinition( + 'acme_mailer.transport_chain') + ) { return; } - $definition = $container->getDefinition('acme_mailer.transport_chain'); + $definition = $container->getDefinition( + 'acme_mailer.transport_chain' + ); - foreach ($container->findTaggedServiceIds('acme_mailer.transport') as $id => $tagAttributes) { + $taggedServices = $container->findTaggedServiceIds( + 'acme_mailer.transport' + ); + foreach ($taggedServices as $id => $tagAttributes) { foreach ($tagAttributes as $attributes) { - $definition->addMethodCall('addTransport', array(new Reference($id), $attributes["alias"])); + $definition->addMethodCall( + 'addTransport', + array(new Reference($id), $attributes["alias"]) + ); } } } From b4e99f381f3a343cfeffb0f43a6e93d702820fb2 Mon Sep 17 00:00:00 2001 From: Richard Miller Date: Mon, 24 Sep 2012 21:04:55 +0100 Subject: [PATCH 2/2] Fixing CS in tags example --- components/dependency_injection/tags.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/dependency_injection/tags.rst b/components/dependency_injection/tags.rst index e75169b896a..8f439e40304 100644 --- a/components/dependency_injection/tags.rst +++ b/components/dependency_injection/tags.rst @@ -128,9 +128,7 @@ custom tag:: { public function process(ContainerBuilder $container) { - if (false === $container->hasDefinition( - 'acme_mailer.transport_chain' - )) { + if (!$container->hasDefinition('acme_mailer.transport_chain')) { return; } @@ -252,9 +250,7 @@ use this, update the compiler:: { public function process(ContainerBuilder $container) { - if (false === $container->hasDefinition( - 'acme_mailer.transport_chain') - ) { + if (!$container->hasDefinition('acme_mailer.transport_chain')) { return; }