Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public function process(ContainerBuilder $container)
{
$namespaceSuffix = '';

foreach (array('name', 'root_dir', 'environment', 'debug') as $key) {
if ($container->hasParameter('kernel.'.$key)) {
$namespaceSuffix .= '.'.$container->getParameter('kernel.'.$key);
foreach (array('kernel.name', 'kernel.environment', 'kernel.debug', 'cache.prefix.seed') as $key) {
if ($container->hasParameter($key)) {
$namespaceSuffix .= '.'.$container->getParameter($key);
}
}
$container->getParameterBag()->remove('cache.prefix.seed');

$aliases = $container->getAliases();
$attributes = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,10 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
->addDefaultsIfNotSet()
->fixXmlConfig('pool')
->children()
->scalarNode('prefix_seed')
->info('Used to namespace cache keys when using several apps with the same shared backend')
->example('my-application-name')
->end()
->scalarNode('app')
->info('App related cache pools configuration')
->defaultValue('cache.adapter.filesystem')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,9 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);

if (isset($config['prefix_seed'])) {
$container->setParameter('cache.prefix.seed', $config['prefix_seed']);
Copy link
Contributor

@ro0NL ro0NL Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not setting it directly on the pass it self? Yes; foreaching all passes to find any instance of CachePoolPass.

Otherwise maybe use a less generic name, to clarify something's going on (it's a tmp thingy, only to transfer config..), ie. setParameter(CachePoolPass::class.'_prefix_seed').

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To achieve which goal?

Copy link
Contributor

@ro0NL ro0NL Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess to avoid creating params into the wild and making things less implicit. Im fine with it though.. just curious :)

This mix&matches framework.cache.prefix_seed and %cache.prefix.seed%, they're the same. In apps this often shows a code smell, as people tend to use params as some global config array, by exactly doing this.

}
foreach (array('doctrine', 'psr6', 'redis') as $name) {
if (isset($config[$name = 'default_'.$name.'_provider'])) {
$container->setAlias('cache.'.$name, Compiler\CachePoolPass::getServiceProvider($container, $config[$name]));
Expand Down