Skip to content

Commit

Permalink
Merge pull request #173 from martiis/modifier-pass
Browse files Browse the repository at this point in the history
Added modifier class pass
  • Loading branch information
Martynas Sudintas committed Apr 8, 2015
2 parents 0289dde + b9de2bb commit 745b536
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions DependencyInjection/Compiler/ModifierClassPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace ONGR\ConnectionsBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Sets modifier class to abstract service.
*/
class ModifierClassPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if ($container->hasParameter('ongr_connections.import.modifier.class')) {
$container
->getDefinition('ongr_connections.import.modifier')
->setClass($container->getParameter('ongr_connections.import.modifier.class'));
}
}
}
2 changes: 2 additions & 0 deletions ONGRConnectionsBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace ONGR\ConnectionsBundle;

use ONGR\ConnectionsBundle\DependencyInjection\Compiler\ExtractionDescriptorPass;
use ONGR\ConnectionsBundle\DependencyInjection\Compiler\ModifierClassPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

Expand All @@ -28,5 +29,6 @@ public function build(ContainerBuilder $container)
parent::build($container);

$container->addCompilerPass(new ExtractionDescriptorPass());
$container->addCompilerPass(new ModifierClassPass());
}
}
2 changes: 1 addition & 1 deletion Tests/app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ services:
- { name: kernel.event_listener, event: ongr.pipeline.import.default.source, method: onSource }

test.import.modifier:
class: %ongr_connections.import.modifier.class%
parent: ongr_connections.import.modifier
tags:
- { name: kernel.event_listener, event: ongr.pipeline.import.default.modify, method: onModify }

Expand Down

0 comments on commit 745b536

Please sign in to comment.