Skip to content

Commit 1bc901a

Browse files
committed
Removed the BaseCompilerPass
1 parent 8aa3ba3 commit 1bc901a

File tree

4 files changed

+30
-68
lines changed

4 files changed

+30
-68
lines changed

src/DependencyInjection/Compiler/BaseCompilerPass.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/DependencyInjection/Compiler/DataCollectorCompilerPass.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Cache\CacheBundle\DependencyInjection\Compiler;
1313

1414
use Cache\CacheBundle\Cache\LoggingCachePool;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1517
use Symfony\Component\DependencyInjection\Reference;
1618

1719
/**
@@ -20,20 +22,20 @@
2022
* @author Aaron Scherer <aequasi@gmail.com>
2123
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
2224
*/
23-
class DataCollectorCompilerPass extends BaseCompilerPass
25+
class DataCollectorCompilerPass implements CompilerPassInterface
2426
{
2527
/**
2628
* {@inheritdoc}
2729
*/
28-
protected function prepare()
30+
public function process(ContainerBuilder $container)
2931
{
30-
$collectorDefinition = $this->container->getDefinition('cache.data_collector');
31-
$serviceIds = $this->container->findTaggedServiceIds('cache.provider');
32+
$collectorDefinition = $container->getDefinition('cache.data_collector');
33+
$serviceIds = $container->findTaggedServiceIds('cache.provider');
3234

3335
foreach (array_keys($serviceIds) as $id) {
3436

3537
// Creating a LoggingCachePool instance, and passing it the new definition from above
36-
$def = $this->container->register($id.'.logger', LoggingCachePool::class);
38+
$def = $container->register($id.'.logger', LoggingCachePool::class);
3739
$def->addArgument(new Reference($id.'.logger.inner'))
3840
->setDecoratedService($id, null, 10);
3941

src/DependencyInjection/Compiler/DoctrineSupportCompilerPass.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Cache\Bridge\DoctrineCacheBridge;
1515
use Cache\CacheBundle\Cache\FixedTaggingCachePool;
1616
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
17+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1719
use Symfony\Component\DependencyInjection\Reference;
1820

1921
/**
@@ -22,15 +24,16 @@
2224
* @author Aaron Scherer <aequasi@gmail.com>
2325
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
2426
*/
25-
class DoctrineSupportCompilerPass extends BaseCompilerPass
27+
class DoctrineSupportCompilerPass implements CompilerPassInterface
2628
{
2729
/**
2830
* @throws \Exception
2931
*
3032
* @return void
3133
*/
32-
protected function prepare()
34+
public function process(ContainerBuilder $container)
3335
{
36+
$this->container = $container;
3437
// If disabled, continue
3538
if (!$this->container->hasParameter('cache.doctrine')) {
3639
return;

src/DependencyInjection/Compiler/SessionSupportCompilerPass.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use Cache\CacheBundle\Session\SessionHandler;
1515
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
16+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1618
use Symfony\Component\DependencyInjection\Definition;
1719
use Symfony\Component\DependencyInjection\Reference;
1820

@@ -21,24 +23,30 @@
2123
*
2224
* @author Aaron Scherer <aequasi@gmail.com>
2325
*/
24-
class SessionSupportCompilerPass extends BaseCompilerPass
26+
class SessionSupportCompilerPass implements CompilerPassInterface
2527
{
2628
/**
27-
*
29+
* @type ContainerBuilder
30+
*/
31+
protected $container;
32+
33+
/**
34+
* @param ContainerBuilder $container
35+
* @throws \Exception
2836
*/
29-
protected function prepare()
37+
public function process(ContainerBuilder $container)
3038
{
3139
// Check if session support is enabled
32-
if (!$this->container->hasParameter($this->getAlias().'.session')) {
40+
if (!$container->hasParameter('cache.session')) {
3341
return;
3442
}
3543

3644
// If there is no active session support, throw
37-
if (!$this->container->hasAlias('session.storage')) {
45+
if (!$container->hasAlias('session.storage')) {
3846
throw new \Exception('Session cache support cannot be enabled if there is no session.storage service');
3947
}
4048

41-
$this->enableSessionSupport($this->container->getParameter($this->getAlias().'.session'));
49+
$this->enableSessionSupport($container, $container->getParameter('cache.session'));
4250
}
4351

4452
/**
@@ -48,10 +56,10 @@ protected function prepare()
4856
*
4957
* @throws InvalidConfigurationException
5058
*/
51-
private function enableSessionSupport(array $config)
59+
private function enableSessionSupport(ContainerBuilder $container, array $config)
5260
{
5361
// calculate options
54-
$sessionOptions = $this->container->getParameter('session.storage.options');
62+
$sessionOptions = $container->getParameter('session.storage.options');
5563
if (isset($sessionOptions['cookie_lifetime']) && !isset($config['cookie_lifetime'])) {
5664
$config['cookie_lifetime'] = $sessionOptions['cookie_lifetime'];
5765
}
@@ -60,8 +68,8 @@ private function enableSessionSupport(array $config)
6068
$definition->addArgument(new Reference($config['service_id']))
6169
->addArgument($config);
6270

63-
$this->container->setDefinition('cache.session_handler', $definition);
71+
$container->setDefinition('cache.session_handler', $definition);
6472

65-
$this->container->setAlias('session.handler', 'cache.session_handler');
73+
$container->setAlias('session.handler', 'cache.session_handler');
6674
}
6775
}

0 commit comments

Comments
 (0)