Skip to content

Commit b6943d4

Browse files
committed
Merge pull request #30 from aequasi/master
Fixing reference replacement
2 parents a68b11e + 535739e commit b6943d4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/DependencyInjection/CacheAdapterExtension.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ public function load(array $configs, ContainerBuilder $container)
4848
$factoryClass::validate($arguments['options'], $name);
4949

5050
// See if any option has a service reference
51-
foreach ($arguments['options'] as $key => $value) {
52-
if (substr($key, -8) === '_service' || strpos($value, '@') === 0) {
53-
$arguments['options'][$key] = new Reference($value);
54-
}
55-
}
51+
$arguments['options'] = $this->findReferences($arguments['options']);
5652

5753
$def = $container->register('cache.provider.'.$name, DummyAdapter::class);
5854
$def->setFactory([new Reference($arguments['factory']), 'createAdapter'])
@@ -63,4 +59,22 @@ public function load(array $configs, ContainerBuilder $container)
6359

6460
$container->setAlias('cache', 'cache.provider.'.$first);
6561
}
62+
63+
/**
64+
* @param array $options
65+
*
66+
* @return array
67+
*/
68+
private function findReferences(array $options)
69+
{
70+
foreach ($options as $key => $value) {
71+
if (is_array($value)) {
72+
$options[$key] = $this->findReferences($value);
73+
} elseif (substr($key, -8) === '_service' || strpos($value, '@') === 0) {
74+
$options[$key] = new Reference(ltrim($value, '@'));
75+
}
76+
}
77+
78+
return $options;
79+
}
6680
}

0 commit comments

Comments
 (0)