Skip to content

Commit 9d429ca

Browse files
committed
Bugfixes and improvements
1 parent 8f8763a commit 9d429ca

File tree

7 files changed

+45
-38
lines changed

7 files changed

+45
-38
lines changed

LICENSE

100644100755
File mode changed.

README.md

100644100755
File mode changed.

src/DependencyInjection/CompilerPass/ServiceBuilderPass.php

100644100755
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class ServiceBuilderPass implements CompilerPassInterface
3737
*/
3838
public function process(ContainerBuilder $container)
3939
{
40-
$providers = $container->getParameter('doctrine_cache.providers');
40+
$providers = $container->getParameter('cache_adapter_doctrine.providers');
4141

4242
foreach ($providers as $name => $provider) {
43-
$typeServiceId = 'doctrine_cache.abstract.'.$provider['type'];
43+
$typeServiceId = 'cache.doctrine_adapter.abstract.'.$provider['type'];
4444
if (!$container->hasDefinition($typeServiceId)) {
4545
throw new InvalidConfigurationException(
4646
sprintf(
@@ -70,11 +70,9 @@ private function createPsr7CompliantService(ContainerBuilder $container, $typeSe
7070
$serviceId = 'cache.doctrine_adapter.provider.'.$name;
7171

7272
// Register the CacheItemPoolInterface definition
73-
$def = $container->setDefinition(
74-
$serviceId,
75-
\Cache\Doctrine\CachePoolItem::class
76-
);
77-
$def->addArgument(0, new Reference($typeServiceId));
73+
$def = new Definition(\Cache\Doctrine\CachePoolItem::class);
74+
$def->addArgument(new Reference($typeServiceId));
75+
$container->setDefinition($serviceId, $def);
7876

7977
$container->setAlias('cache.provider.'.$name, $serviceId);
8078
}
@@ -91,8 +89,8 @@ private function prepareDoctrineCacheClass(ContainerBuilder $container, $typeSer
9189
$namespace = is_null($provider['namespace']) ? $name : $provider['namespace'];
9290

9391
// Modify the core doctrine cache class
94-
$service = $container->getDefinition($typeServiceId);
95-
$service->addMethodCall('setNamespace', [$namespace])
92+
$definition = $container->getDefinition($typeServiceId);
93+
$definition->addMethodCall('setNamespace', [$namespace])
9694
->setPublic(false);
9795

9896
$type = $provider['type'];
@@ -109,8 +107,7 @@ private function prepareDoctrineCacheClass(ContainerBuilder $container, $typeSer
109107
$container->setDefinition($providerHelperServiceId, $providerHelperDefinition);
110108
}
111109

112-
$service->addMethodCall(sprintf('set%s', ucwords($type)), [new Reference($providerHelperServiceId)]);
113-
110+
$definition->addMethodCall(sprintf('set%s', ucwords($type)), [new Reference($providerHelperServiceId)]);
114111
break;
115112
case 'file_system':
116113
case 'php_file':
@@ -119,8 +116,7 @@ private function prepareDoctrineCacheClass(ContainerBuilder $container, $typeSer
119116
$directory = $provider['directory'];
120117
}
121118
$extension = is_null($provider['extension']) ? null : $provider['extension'];
122-
123-
$service->setArguments([$directory, $extension]);
119+
$definition->setArguments([$directory, $extension]);
124120

125121
break;
126122
case 'mongo':
@@ -130,6 +126,9 @@ private function prepareDoctrineCacheClass(ContainerBuilder $container, $typeSer
130126
case 'chain':
131127
break;
132128
}
129+
130+
// TODO is this line needed?
131+
$container->setDefinition($typeServiceId, $definition);
133132
}
134133

135134
/**

src/DoctrineAdapterBundle.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,30 @@
22

33
namespace Cache\Adapter\DoctrineAdapterBundle;
44

5+
use Cache\Adapter\DoctrineAdapterBundle\DependencyInjection\CompilerPass\ServiceBuilderPass;
6+
use Cache\Adapter\DoctrineAdapterBundle\DependencyInjection\DoctrineAdapterExtension;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
58
use Symfony\Component\HttpKernel\Bundle\Bundle;
69

710
/**
811
* @author Tobias Nyholm <[email protected]>
912
*/
1013
class DoctrineAdapterBundle extends Bundle
1114
{
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function build(ContainerBuilder $container)
19+
{
20+
parent::build($container);
21+
$container->addCompilerPass(new ServiceBuilderPass());
22+
}
23+
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function getContainerExtension()
28+
{
29+
return new DoctrineAdapterExtension();
30+
}
1231
}

src/ProviderHelper/Memcached.php

100644100755
File mode changed.

src/Resources/config/services.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
11

22
services:
3-
doctrine_cache.abstract.apc:
3+
cache.doctrine_adapter.abstract.apc:
44
class: Doctrine\Common\Cache\ApcCache
5-
abstract: true
65

7-
doctrine_cache.abstract.array:
6+
cache.doctrine_adapter.abstract.array:
87
class: Doctrine\Common\Cache\ArrayCache
9-
abstract: true
108

11-
doctrine_cache.abstract.file_system:
9+
cache.doctrine_adapter.abstract.file_system:
1210
class: Doctrine\Common\Cache\FilesystemCache
13-
abstract: true
1411

15-
doctrine_cache.abstract.memcache:
12+
cache.doctrine_adapter.abstract.memcache:
1613
class: Doctrine\Common\Cache\MemcacheCache
17-
abstract: true
1814

19-
doctrine_cache.abstract.memcached:
15+
cache.doctrine_adapter.abstract.memcached:
2016
class: Doctrine\Common\Cache\MemcachedCache
21-
abstract: true
2217

23-
doctrine_cache.abstract.redis:
18+
cache.doctrine_adapter.abstract.redis:
2419
class: Doctrine\Common\Cache\RedisCache
25-
abstract: true
2620

27-
doctrine_cache.abstract.php_file:
21+
cache.doctrine_adapter.abstract.php_file:
2822
class: Doctrine\Common\Cache\PhpFileCache
29-
abstract: true
3023

31-
doctrine_cache.abstract.win_cache:
24+
cache.doctrine_adapter.abstract.win_cache:
3225
class: Doctrine\Common\Cache\WinCacheCache
33-
abstract: true
3426

35-
doctrine_cache.abstract.xcache:
27+
cache.doctrine_adapter.abstract.xcache:
3628
class: Doctrine\Common\Cache\XcacheCache
37-
abstract: true
3829

39-
doctrine_cache.zend_data:
30+
cache.doctrine_adapter.zend_data:
4031
class: Doctrine\Common\Cache\ZendDataCache
41-
abstract: true
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
<?php
22

3-
namespace Cache\Adapter\DoctrineAdapterBundle\Tests\DependencyInjection;
3+
namespace Cache\Adapter\DoctrineAdapterBundle\tests\DependencyInjection;
44

55
use Cache\Adapter\DoctrineAdapterBundle\DependencyInjection\DoctrineAdapterExtension;
66
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
77

88
class DoctrineCacheExtensionTest extends AbstractExtensionTestCase
99
{
10-
1110
protected function getContainerExtensions()
1211
{
1312
return array(
14-
new DoctrineAdapterExtension()
13+
new DoctrineAdapterExtension(),
1514
);
1615
}
1716

1817
public function testThatProvidersExists()
1918
{
20-
$providers = array('foo' => ['type'=>'apc']);
19+
$providers = array('foo' => ['type' => 'apc']);
2120
$this->load(array('providers' => $providers));
2221

2322
$this->assertContainerBuilderHasParameter('cache_adapter_doctrine.providers');
2423
}
25-
}
24+
}

0 commit comments

Comments
 (0)