Skip to content

Commit c712fdf

Browse files
committed
Merge pull request #1744 from richardmiller/fixing_line_lengths_in_di
Fixing line length to avoid horizontal scrolling in DI component
2 parents 0e74bf9 + b4e99f3 commit c712fdf

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

components/dependency_injection/compilation.rst

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ A very simple extension may just load configuration files into the container::
6161
{
6262
public function load(array $configs, ContainerBuilder $container)
6363
{
64-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
64+
$loader = new XmlFileLoader(
65+
$container,
66+
new FileLocator(__DIR__.'/../Resources/config')
67+
);
6568
$loader->load('services.xml');
6669
}
6770

@@ -225,7 +228,10 @@ but also load a secondary one only if a certain parameter is set::
225228
$processor = new Processor();
226229
$config = $processor->processConfiguration($configuration, $configs);
227230

228-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
231+
$loader = new XmlFileLoader(
232+
$container,
233+
new FileLocator(__DIR__.'/../Resources/config')
234+
);
229235
$loader->load('services.xml');
230236

231237
if ($config['advanced']) {
@@ -309,7 +315,10 @@ For example, to run your custom pass after the default removal passes have been
309315
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
310316

311317
$container = new ContainerBuilder();
312-
$container->addCompilerPass(new CustomCompilerPass, PassConfig::TYPE_AFTER_REMOVING);
318+
$container->addCompilerPass(
319+
new CustomCompilerPass,
320+
PassConfig::TYPE_AFTER_REMOVING
321+
);
313322

314323
.. _components-dependency-injection-dumping:
315324

@@ -357,7 +366,10 @@ it::
357366
$container->compile();
358367

359368
$dumper = new PhpDumper($container);
360-
file_put_contents($file, $dumper->dump(array('class' => 'MyCachedContainer')));
369+
file_put_contents(
370+
$file,
371+
$dumper->dump(array('class' => 'MyCachedContainer'))
372+
);
361373
}
362374

363375
You will now get the speed of the PHP configured container with the ease of using
@@ -386,7 +398,10 @@ but getting an up to date configuration whilst developing your application::
386398

387399
if (!$isDebug) {
388400
$dumper = new PhpDumper($container);
389-
file_put_contents($file, $dumper->dump(array('class' => 'MyCachedContainer')));
401+
file_put_contents(
402+
$file,
403+
$dumper->dump(array('class' => 'MyCachedContainer'))
404+
);
390405
}
391406
}
392407

components/dependency_injection/tags.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,22 @@ custom tag::
128128
{
129129
public function process(ContainerBuilder $container)
130130
{
131-
if (false === $container->hasDefinition('acme_mailer.transport_chain')) {
131+
if (!$container->hasDefinition('acme_mailer.transport_chain')) {
132132
return;
133133
}
134134

135-
$definition = $container->getDefinition('acme_mailer.transport_chain');
136-
137-
foreach ($container->findTaggedServiceIds('acme_mailer.transport') as $id => $attributes) {
138-
$definition->addMethodCall('addTransport', array(new Reference($id)));
135+
$definition = $container->getDefinition(
136+
'acme_mailer.transport_chain'
137+
);
138+
139+
$taggedServices = $container->findTaggedServiceIds(
140+
'acme_mailer.transport'
141+
);
142+
foreach ($taggedServices as $id => $attributes) {
143+
$definition->addMethodCall(
144+
'addTransport',
145+
array(new Reference($id))
146+
);
139147
}
140148
}
141149
}
@@ -242,15 +250,23 @@ use this, update the compiler::
242250
{
243251
public function process(ContainerBuilder $container)
244252
{
245-
if (false === $container->hasDefinition('acme_mailer.transport_chain')) {
253+
if (!$container->hasDefinition('acme_mailer.transport_chain')) {
246254
return;
247255
}
248256

249-
$definition = $container->getDefinition('acme_mailer.transport_chain');
257+
$definition = $container->getDefinition(
258+
'acme_mailer.transport_chain'
259+
);
250260

251-
foreach ($container->findTaggedServiceIds('acme_mailer.transport') as $id => $tagAttributes) {
261+
$taggedServices = $container->findTaggedServiceIds(
262+
'acme_mailer.transport'
263+
);
264+
foreach ($taggedServices as $id => $tagAttributes) {
252265
foreach ($tagAttributes as $attributes) {
253-
$definition->addMethodCall('addTransport', array(new Reference($id), $attributes["alias"]));
266+
$definition->addMethodCall(
267+
'addTransport',
268+
array(new Reference($id), $attributes["alias"])
269+
);
254270
}
255271
}
256272
}

0 commit comments

Comments
 (0)