Skip to content

Commit

Permalink
[Extension] Remove purger from container in compiler pass (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatkoverk committed Sep 1, 2021
1 parent ffc098d commit 53573c7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace SofaScore\Purgatory\DependencyInjection\CompilerPass;


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

class SymfonyPurgerRemovalCompilerPass implements CompilerPassInterface
{

public function process(ContainerBuilder $container)
{
if (!$container->has('http_cache.store')) {
$container->removeDefinition('sofascore.purgatory.purger.symfony');
}
}
}
5 changes: 0 additions & 5 deletions DependencyInjection/PurgatoryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\HttpCache\Store;

final class PurgatoryExtension extends Extension
{
Expand All @@ -28,9 +27,5 @@ public function load(array $configs, ContainerBuilder $container)
if (!$config['entity_change_listener']) {
$container->removeDefinition('sofascore.purgatory.entity_change_listener');
}

if (!$container->has(Store::class)) {
$container->removeDefinition('sofascore.purgatory.purger.symfony');
}
}
}
2 changes: 2 additions & 0 deletions PurgatoryBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SofaScore\Purgatory;

use SofaScore\Purgatory\DependencyInjection\CompilerPass\RegisterPurgerImplementationCompilerPass;
use SofaScore\Purgatory\DependencyInjection\CompilerPass\SymfonyPurgerRemovalCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

Expand All @@ -16,5 +17,6 @@ public function build(ContainerBuilder $container): void
parent::build($container);

$container->addCompilerPass(new RegisterPurgerImplementationCompilerPass());
$container->addCompilerPass(new SymfonyPurgerRemovalCompilerPass());
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sofascore/purgatory",
"description": "Library for easy construction of cache purge requests.",
"type": "library",
"version": "0.2.0",
"version": "0.2.1",
"autoload": {
"psr-4": {
"SofaScore\\Purgatory\\": ""
Expand Down

0 comments on commit 53573c7

Please sign in to comment.