Other files ignored by Codecov
Tests/Migrations/empty/.gitkeep
is new.
README.md
has changed.
12 | 12 | ||
13 | 13 | namespace StfalconStudio\DoctrineRedisCacheBundle\DependencyInjection; |
|
14 | 14 | ||
15 | + | use Doctrine\Migrations\Finder\RecursiveRegexFinder; |
|
15 | 16 | use Symfony\Component\Config\FileLocator; |
|
16 | 17 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17 | 18 | use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
24 | 25 | */ |
|
25 | 26 | class StfalconStudioDoctrineRedisCacheExtension extends Extension |
|
26 | 27 | { |
|
28 | + | /** @var RecursiveRegexFinder */ |
|
29 | + | private $migrationFinder; |
|
30 | + | ||
31 | + | /** |
|
32 | + | * Constructor. |
|
33 | + | */ |
|
34 | + | public function __construct() |
|
35 | + | { |
|
36 | + | $this->migrationFinder = new RecursiveRegexFinder(); |
|
37 | + | } |
|
38 | + | ||
27 | 39 | /** |
|
28 | 40 | * {@inheritdoc} |
|
29 | 41 | */ |
31 | 43 | { |
|
32 | 44 | $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
33 | 45 | $loader->load('services.yaml'); |
|
46 | + | ||
47 | + | $container->setParameter('cache_prefix_seed', $this->getLastMigrationVersion($container->getParameter('doctrine_migrations.dir_name'))); |
|
48 | + | } |
|
49 | + | ||
50 | + | /** |
|
51 | + | * @param string $dir |
|
52 | + | * |
|
53 | + | * @return string |
|
54 | + | */ |
|
55 | + | public function getLastMigrationVersion(string $dir): string |
|
56 | + | { |
|
57 | + | $migrations = $this->migrationFinder->findMigrations($dir); |
|
58 | + | ||
59 | + | $versions = \array_keys($migrations); |
|
60 | + | $latest = \end($versions); |
|
61 | + | ||
62 | + | return false !== $latest ? (string) $latest : '0'; |
|
34 | 63 | } |
|
35 | 64 | } |
Files | Complexity | Coverage |
---|---|---|
Cache/PredisCache.php | 17 | 100.00% |
DependencyInjection/StfalconStudioDoctrineRedisCacheExtension.php | 4 | 100.00% |
Service/Migration/MigrationVersionService.php | 3 | 100.00% |
Project Totals (3 files) | 24 | 100.00% |
7.3=.3 TRAVIS_OS_NAME=linux
7.3=.3 TRAVIS_OS_NAME=linux