Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the deprecated Doctrine cache bundle #1916

Merged
merged 2 commits into from Jul 8, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -50,7 +50,6 @@
"contao/manager-plugin": "^2.6.2",
"doctrine/dbal": "^2.10",
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
"doctrine/doctrine-cache-bundle": "^1.3.1",
"doctrine/orm": "^2.6.3",
"dragonmantank/cron-expression": "^2.3",
"friendsofsymfony/http-cache": "^2.6",
Expand Down
1 change: 0 additions & 1 deletion core-bundle/composer.json
Expand Up @@ -48,7 +48,6 @@
"contao/imagine-svg": "^0.2.3 || ^1.0",
"doctrine/dbal": "^2.10",
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
"doctrine/doctrine-cache-bundle": "^1.3.1",
"doctrine/orm": "^2.6.3",
"dragonmantank/cron-expression": "^2.3",
"friendsofsymfony/http-cache": "^2.6",
Expand Down
2 changes: 0 additions & 2 deletions core-bundle/src/ContaoManager/Plugin.php
Expand Up @@ -18,7 +18,6 @@
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
use Contao\ManagerPlugin\Routing\RoutingPluginInterface;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Knp\Bundle\TimeBundle\KnpTimeBundle;
use Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle;
Expand Down Expand Up @@ -57,7 +56,6 @@ public function getBundles(ParserInterface $parser): array
TwigBundle::class,
MonologBundle::class,
DoctrineBundle::class,
DoctrineCacheBundle::class,
KnpMenuBundle::class,
KnpTimeBundle::class,
LexikMaintenanceBundle::class,
Expand Down
2 changes: 0 additions & 2 deletions core-bundle/tests/ContaoManager/PluginTest.php
Expand Up @@ -17,7 +17,6 @@
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\Parser\DelegatingParser;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Knp\Bundle\TimeBundle\KnpTimeBundle;
use Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle;
Expand Down Expand Up @@ -76,7 +75,6 @@ public function testReturnsTheBundles(): void
TwigBundle::class,
MonologBundle::class,
DoctrineBundle::class,
DoctrineCacheBundle::class,
KnpMenuBundle::class,
KnpTimeBundle::class,
LexikMaintenanceBundle::class,
Expand Down
2 changes: 1 addition & 1 deletion manager-bundle/composer.json
Expand Up @@ -22,13 +22,13 @@
"contao/manager-plugin": "^2.4",
"doctrine/dbal": "^2.10",
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
"doctrine/doctrine-cache-bundle": "^1.3.1",
"friendsofsymfony/http-cache": "^2.6",
"friendsofsymfony/http-cache-bundle": "^2.6",
"lexik/maintenance-bundle": "^2.1.3",
"nelmio/cors-bundle": "^1.5.3 || ^2.0.1",
"nelmio/security-bundle": "^2.2",
"ocramius/proxy-manager": "^2.1",
"symfony/cache": "4.4.*",
"symfony/config": "4.4.*",
"symfony/console": "4.4.*",
"symfony/debug": "4.4.*",
Expand Down
2 changes: 0 additions & 2 deletions manager-bundle/src/ContaoManager/Plugin.php
Expand Up @@ -31,7 +31,6 @@
use Contao\ManagerPlugin\Dependency\DependentPluginInterface;
use Contao\ManagerPlugin\Routing\RoutingPluginInterface;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception\DriverException;
use FOS\HttpCacheBundle\FOSHttpCacheBundle;
Expand Down Expand Up @@ -95,7 +94,6 @@ public function getBundles(ParserInterface $parser)
BundleConfig::create(TwigBundle::class),
BundleConfig::create(MonologBundle::class),
BundleConfig::create(DoctrineBundle::class),
BundleConfig::create(DoctrineCacheBundle::class),
BundleConfig::create(LexikMaintenanceBundle::class),
BundleConfig::create(NelmioCorsBundle::class),
BundleConfig::create(NelmioSecurityBundle::class),
Expand Down
33 changes: 12 additions & 21 deletions manager-bundle/src/Resources/skeleton/config/config.yml
@@ -1,6 +1,7 @@
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }

# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
Expand All @@ -22,6 +23,12 @@ framework:
session:
handler_id: ~
fragments: { path: /_fragment }
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system

# Contao configuration
contao:
Expand Down Expand Up @@ -57,29 +64,13 @@ doctrine:
naming_strategy: doctrine.orm.naming_strategy.default
metadata_cache_driver:
type: service
id: doctrine_cache.providers.doctrine_metadata_cache
result_cache_driver:
type: service
id: doctrine_cache.providers.doctrine_result_cache
id: app.doctrine_system_cache_provider
query_cache_driver:
type: service
id: doctrine_cache.providers.doctrine_query_cache

# Doctrine cache configuration
doctrine_cache:
providers:
doctrine_metadata_cache:
file_system:
extension: .cache
directory: '%kernel.cache_dir%/doctrine/metadata'
doctrine_result_cache:
file_system:
extension: .cache
directory: '%kernel.cache_dir%/doctrine/result'
doctrine_query_cache:
file_system:
extension: .cache
directory: '%kernel.cache_dir%/doctrine/query'
id: app.doctrine_system_cache_provider
result_cache_driver:
type: service
id: app.doctrine_result_cache_provider

# Lexik configuration
lexik_maintenance:
Expand Down
10 changes: 10 additions & 0 deletions manager-bundle/src/Resources/skeleton/config/services.yml
@@ -0,0 +1,10 @@
services:
app.doctrine_result_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
arguments:
- '@doctrine.result_cache_pool'

app.doctrine_system_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
arguments:
- '@doctrine.system_cache_pool'
33 changes: 14 additions & 19 deletions manager-bundle/tests/ContaoManager/PluginTest.php
Expand Up @@ -22,7 +22,6 @@
use Contao\ManagerPlugin\PluginLoader;
use Contao\TestCase\ContaoTestCase;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
use Doctrine\DBAL\Connection;
use FOS\HttpCacheBundle\FOSHttpCacheBundle;
use Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle;
Expand Down Expand Up @@ -83,7 +82,7 @@ public function testReturnsTheBundles(): void
/** @var array<BundleConfig> $bundles */
$bundles = $plugin->getBundles(new DelegatingParser());

$this->assertCount(13, $bundles);
$this->assertCount(12, $bundles);

$this->assertSame(FrameworkBundle::class, $bundles[0]->getName());
$this->assertSame([], $bundles[0]->getReplace());
Expand All @@ -105,39 +104,35 @@ public function testReturnsTheBundles(): void
$this->assertSame([], $bundles[4]->getReplace());
$this->assertSame([], $bundles[4]->getLoadAfter());

$this->assertSame(DoctrineCacheBundle::class, $bundles[5]->getName());
$this->assertSame(LexikMaintenanceBundle::class, $bundles[5]->getName());
$this->assertSame([], $bundles[5]->getReplace());
$this->assertSame([], $bundles[5]->getLoadAfter());

$this->assertSame(LexikMaintenanceBundle::class, $bundles[6]->getName());
$this->assertSame(NelmioCorsBundle::class, $bundles[6]->getName());
$this->assertSame([], $bundles[6]->getReplace());
$this->assertSame([], $bundles[6]->getLoadAfter());

$this->assertSame(NelmioCorsBundle::class, $bundles[7]->getName());
$this->assertSame(NelmioSecurityBundle::class, $bundles[7]->getName());
$this->assertSame([], $bundles[7]->getReplace());
$this->assertSame([], $bundles[7]->getLoadAfter());

$this->assertSame(NelmioSecurityBundle::class, $bundles[8]->getName());
$this->assertSame([], $bundles[9]->getReplace());
$this->assertSame([], $bundles[9]->getLoadAfter());
$this->assertSame(FOSHttpCacheBundle::class, $bundles[8]->getName());
$this->assertSame([], $bundles[8]->getReplace());
$this->assertSame([], $bundles[8]->getLoadAfter());

$this->assertSame(FOSHttpCacheBundle::class, $bundles[9]->getName());
$this->assertSame(ContaoManagerBundle::class, $bundles[9]->getName());
$this->assertSame([], $bundles[9]->getReplace());
$this->assertSame([], $bundles[9]->getLoadAfter());
$this->assertSame([ContaoCoreBundle::class], $bundles[9]->getLoadAfter());

$this->assertSame(ContaoManagerBundle::class, $bundles[10]->getName());
$this->assertSame(DebugBundle::class, $bundles[10]->getName());
$this->assertSame([], $bundles[10]->getReplace());
$this->assertSame([ContaoCoreBundle::class], $bundles[10]->getLoadAfter());
$this->assertSame([], $bundles[10]->getLoadAfter());
$this->assertFalse($bundles[10]->loadInProduction());

$this->assertSame(DebugBundle::class, $bundles[11]->getName());
$this->assertSame(WebProfilerBundle::class, $bundles[11]->getName());
$this->assertSame([], $bundles[11]->getReplace());
$this->assertSame([], $bundles[11]->getLoadAfter());
$this->assertFalse($bundles[11]->loadInProduction());

$this->assertSame(WebProfilerBundle::class, $bundles[12]->getName());
$this->assertSame([], $bundles[12]->getReplace());
$this->assertSame([], $bundles[12]->getLoadAfter());
$this->assertFalse($bundles[12]->loadInProduction());
}

public function testRegistersModuleBundles(): void
Expand All @@ -162,7 +157,7 @@ static function ($resource): array {
$plugin = new Plugin();
$configs = $plugin->getBundles($parser);

$this->assertCount(15, $configs);
$this->assertCount(14, $configs);
$this->assertContains('foo1', $configs);
$this->assertContains('foo2', $configs);
$this->assertNotContains('foo3', $configs);
Expand Down
53 changes: 26 additions & 27 deletions manager-bundle/tests/Fixtures/output/registered_bundles.out
Expand Up @@ -2,31 +2,30 @@
Bundles Registered by Plugin "Contao\CoreBundle\ContaoManager\Plugin"
=====================================================================

---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
Bundle Replaces Load After Environment
---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
Knp\Bundle\MenuBundle\KnpMenuBundle All
---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
Knp\Bundle\TimeBundle\KnpTimeBundle All
---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
Scheb\TwoFactorBundle\SchebTwoFactorBundle All
---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle All
---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
Terminal42\ServiceAnnotationBundle\Terminal42ServiceAnnotationBundle All
---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
Contao\CoreBundle\ContaoCoreBundle core Symfony\Bundle\FrameworkBundle\FrameworkBundle All
Symfony\Bundle\SecurityBundle\SecurityBundle
Symfony\Bundle\TwigBundle\TwigBundle
Symfony\Bundle\MonologBundle\MonologBundle
Doctrine\Bundle\DoctrineBundle\DoctrineBundle
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle
Knp\Bundle\MenuBundle\KnpMenuBundle
Knp\Bundle\TimeBundle\KnpTimeBundle
Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle
Nelmio\CorsBundle\NelmioCorsBundle
Nelmio\SecurityBundle\NelmioSecurityBundle
Scheb\TwoFactorBundle\SchebTwoFactorBundle
Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle
---------------------------------------------------------------------- ---------- --------------------------------------------------------- -------------
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------
Bundle Replaces Load After Environment
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------
Knp\Bundle\MenuBundle\KnpMenuBundle All
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------
Knp\Bundle\TimeBundle\KnpTimeBundle All
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------
Scheb\TwoFactorBundle\SchebTwoFactorBundle All
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------
Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle All
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------
Terminal42\ServiceAnnotationBundle\Terminal42ServiceAnnotationBundle All
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------
Contao\CoreBundle\ContaoCoreBundle core Symfony\Bundle\FrameworkBundle\FrameworkBundle All
Symfony\Bundle\SecurityBundle\SecurityBundle
Symfony\Bundle\TwigBundle\TwigBundle
Symfony\Bundle\MonologBundle\MonologBundle
Doctrine\Bundle\DoctrineBundle\DoctrineBundle
Knp\Bundle\MenuBundle\KnpMenuBundle
Knp\Bundle\TimeBundle\KnpTimeBundle
Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle
Nelmio\CorsBundle\NelmioCorsBundle
Nelmio\SecurityBundle\NelmioSecurityBundle
Scheb\TwoFactorBundle\SchebTwoFactorBundle
Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle
---------------------------------------------------------------------- ---------- ------------------------------------------------------- -------------