Skip to content

Commit

Permalink
DI: configure cache driver explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil authored and Milan Felix Šulc committed Jun 14, 2018
1 parent 181e302 commit d78ca1c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/DI/AnnotationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function loadConfiguration(): void
$builder->addDefinition($this->prefix('reader'))
->setClass(Reader::class)
->setFactory(CachedReader::class, [
0 => $this->prefix('@delegatedReader'),
// 1 => cache is autowired
2 => $config['debug'],
$this->prefix('@delegatedReader'),
$this->prefix('@cache'),
$config['debug'],
]);

AnnotationRegistry::registerUniqueLoader('class_exists');
Expand All @@ -63,19 +63,23 @@ protected function loadCacheConfiguration(): void
if ($config['cache'] === FilesystemCache::class) {
$path = $builder->expand('%tempDir%/cache/Doctrine.Annotations');
$builder->addDefinition($this->prefix('cache'))
->setFactory($config['cache'], [$path]);
->setFactory($config['cache'], [$path])
->setAutowired(false);
} else {
$builder->addDefinition($this->prefix('cache'))
->setFactory($config['cache']);
->setFactory($config['cache'])
->setAutowired(false);
}
} elseif ($config['cache'] instanceof Statement) {
// Filled by other service
$builder->addDefinition($this->prefix('cache'))
->setFactory($config['cache']);
->setFactory($config['cache'])
->setAutowired(false);
} elseif (!$config['cache']) {
// No cache (memory only)
$builder->addDefinition($this->prefix('cache'))
->setFactory(ArrayCache::class);
->setFactory(ArrayCache::class)
->setAutowired(false);
}
}

Expand Down

0 comments on commit d78ca1c

Please sign in to comment.