Skip to content

Commit

Permalink
Added support for tag autoconfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltar van der Berg committed Nov 23, 2017
1 parent c09052e commit a793399
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions LiipMonitorBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
use Liip\MonitorBundle\DependencyInjection\Compiler\AddGroupsCompilerPass;
use Liip\MonitorBundle\DependencyInjection\Compiler\AdditionalReporterCompilerPass;
use Liip\MonitorBundle\DependencyInjection\Compiler\CheckCollectionTagCompilerPass;
use Liip\MonitorBundle\DependencyInjection\Compiler\CheckTagCompilerPass;
use Liip\MonitorBundle\DependencyInjection\Compiler\GroupRunnersCompilerPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Liip\MonitorBundle\DependencyInjection\Compiler\CheckTagCompilerPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class LiipMonitorBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
if (method_exists($container, 'registerForAutoconfiguration')) {
$container->registerForAutoconfiguration('ZendDiagnostics\Check\CheckInterface')
->addTag('liip_monitor.check');
}

$container->addCompilerPass(new AddGroupsCompilerPass());
$container->addCompilerPass(new GroupRunnersCompilerPass());
$container->addCompilerPass(new CheckTagCompilerPass());
Expand Down
11 changes: 11 additions & 0 deletions Tests/LiipMonitorBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Liip\MonitorBundle\Tests;

use Liip\MonitorBundle\LiipMonitorBundle;
use Symfony\Component\DependencyInjection\ChildDefinition;

/**
* Liip\MonitorBundle\Tests\LiipMonitorBundleTest.
Expand Down Expand Up @@ -42,8 +43,18 @@ function ($compilerPass) use (&$compilerPasses) {
}
);

$definition = null;

if (method_exists('Symfony\Component\DependencyInjection\ContainerBuilder', 'registerForAutoconfiguration')) {
$this->container->method('registerForAutoconfiguration')->willReturn($definition = new ChildDefinition(''));
}

$this->bundle->build($this->container);
$this->assertEmpty($compilerPasses);

if ($definition) {
$this->assertTrue($definition->hasTag('liip_monitor.check'));
}
}

/**
Expand Down

0 comments on commit a793399

Please sign in to comment.