stfalcon-studio / DoctrineRedisCacheBundle

@@ -0,0 +1,48 @@
Loading
1 +
<?php
2 +
/*
3 +
 * This file is part of the StfalconStudioDoctrineRedisCacheBundle.
4 +
 *
5 +
 * (c) Stfalcon LLC <stfalcon.com>
6 +
 *
7 +
 * For the full copyright and license information, please view the LICENSE
8 +
 * file that was distributed with this source code.
9 +
 */
10 +
11 +
declare(strict_types=1);
12 +
13 +
namespace StfalconStudio\DoctrineRedisCacheBundle\DependencyInjection;
14 +
15 +
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
16 +
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17 +
use Symfony\Component\Config\Definition\ConfigurationInterface;
18 +
19 +
/**
20 +
 * Configuration.
21 +
 *
22 +
 * @author Artem Henvald <genvaldartem@gmail.com>
23 +
 */
24 +
class Configuration implements ConfigurationInterface
25 +
{
26 +
    /**
27 +
     * {@inheritdoc}
28 +
     */
29 +
    public function getConfigTreeBuilder(): TreeBuilder
30 +
    {
31 +
        $treeBuilder = new TreeBuilder('stfalcon_studio_doctrine_redis_cache');
32 +
33 +
        /** @var ArrayNodeDefinition $root */
34 +
        $root = $treeBuilder->getRootNode();
35 +
36 +
        $root
37 +
            ->children()
38 +
                ->arrayNode('cache_pools')
39 +
                    ->info('A list of cache pools for which should be set the custom namespace.')
40 +
                    ->prototype('scalar')->end()
41 +
                    ->defaultValue([])
42 +
                ->end()
43 +
            ->end()
44 +
        ;
45 +
46 +
        return $treeBuilder;
47 +
    }
48 +
}

@@ -61,8 +61,20 @@
Loading
61 61
        \sort($processedMigrations); // Sort by name
62 62
        $latest = \end($processedMigrations);
63 63
64 -
        if (false !== $latest) {
65 -
            $container->setParameter('cache.prefix.seed', (string) $latest);
64 +
        $cachePools = [];
65 +
        if ($container->hasParameter('doctrine_redis_cache.cache_pools')) {
66 +
            $cachePools = (array) $container->getParameter('doctrine_redis_cache.cache_pools');
67 +
        }
68 +
69 +
        if (false !== $latest && !empty($cachePools)) {
70 +
            $latestMigration = (string) $latest;
71 +
72 +
            foreach ($cachePools as $cachePool) {
73 +
                $definition = $container->getDefinition($cachePool);
74 +
                $tags = $definition->getTags();
75 +
                $tags['cache.pool'][0]['namespace'] = $latestMigration;
76 +
                $definition->setTags($tags);
77 +
            }
66 78
        }
67 79
    }
68 80
}

@@ -29,9 +29,11 @@
Loading
29 29
     */
30 30
    public function load(array $configs, ContainerBuilder $container): void
31 31
    {
32 +
        $configuration = new Configuration();
33 +
        $config = $this->processConfiguration($configuration, $configs);
34 +
        $container->setParameter('doctrine_redis_cache.cache_pools', $config['cache_pools']);
35 +
32 36
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
33 37
        $loader->load('services.yaml');
34 -
35 -
        $container->setParameter('cache_prefix_seed', '0');
36 38
    }
37 39
}
Files Complexity Coverage
DependencyInjection 14 100.00%
StfalconStudioDoctrineRedisCacheBundle.php 1 100.00%
Project Totals (4 files) 15 100.00%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading