Skip to content

Fixing line length to avoid horizontal scrolling in DI component #1744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions components/dependency_injection/compilation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down Expand Up @@ -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']) {
Expand Down Expand Up @@ -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
-----------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'))
);
}
}

Expand Down
38 changes: 29 additions & 9 deletions components/dependency_injection/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,24 @@ custom tag::
{
public function process(ContainerBuilder $container)
{
if (false === $container->hasDefinition('acme_mailer.transport_chain')) {
if (false === $container->hasDefinition(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could change it to if (!container->hasDefinition()) { instead of false ===. It would follow the Sf2 CS and save 9 chars in the line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, updated, thanks.

'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))
);
}
}
}
Expand Down Expand Up @@ -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"])
);
}
}
}
Expand Down