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

Use Symfony Cache Clear in ModuleManager instead of deprecated CacheClearer #12022

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
14 changes: 7 additions & 7 deletions src/Core/Addon/Module/ModuleManager.php
Expand Up @@ -27,7 +27,6 @@
namespace PrestaShop\PrestaShop\Core\Addon\Module;

use Exception;
use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer;
use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider;
use PrestaShop\PrestaShop\Adapter\Module\Module;
use PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider;
Expand All @@ -36,6 +35,7 @@
use PrestaShop\PrestaShop\Core\Addon\AddonManagerInterface;
use PrestaShop\PrestaShop\Core\Addon\AddonsCollection;
use PrestaShop\PrestaShop\Core\Addon\Module\Exception\UnconfirmedModuleActionException;
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface;
use PrestaShopBundle\Event\ModuleManagementEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
Expand Down Expand Up @@ -96,9 +96,9 @@ class ModuleManager implements AddonManagerInterface
private $actionParams;

/**
* @var CacheClearer
* @var CacheClearerInterface
*/
private $cacheClearer;
private $symfonyCacheClearer;

/**
* Used to check if the cache has already been cleaned.
Expand All @@ -115,7 +115,7 @@ class ModuleManager implements AddonManagerInterface
* @param ModuleZipManager $moduleZipManager
* @param TranslatorInterface $translator
* @param EventDispatcherInterface $eventDispatcher
* @param CacheClearer $cacheClearer
* @param CacheClearerInterface $symfonyCacheClearer
*/
public function __construct(
AdminModuleDataProvider $adminModuleProvider,
Expand All @@ -125,7 +125,7 @@ public function __construct(
ModuleZipManager $moduleZipManager,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
CacheClearer $cacheClearer
CacheClearerInterface $symfonyCacheClearer
) {
$this->adminModuleProvider = $adminModuleProvider;
$this->moduleProvider = $modulesProvider;
Expand All @@ -134,7 +134,7 @@ public function __construct(
$this->moduleZipManager = $moduleZipManager;
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->cacheClearer = $cacheClearer;
$this->symfonyCacheClearer = $symfonyCacheClearer;
$this->actionParams = new ParameterBag();
}

Expand Down Expand Up @@ -810,7 +810,7 @@ private function clearCache()
return;
}

$this->cacheClearer->clearSymfonyCache();
$this->symfonyCacheClearer->clear();
$this->cacheCleared = true;
}
}
9 changes: 1 addition & 8 deletions src/Core/Addon/Module/ModuleManagerBuilder.php
Expand Up @@ -32,7 +32,6 @@
use Doctrine\Common\Cache\FilesystemCache;
use GuzzleHttp\Client;
use PrestaShop\PrestaShop\Adapter\Addons\AddonsDataProvider;
use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer;
use PrestaShop\PrestaShop\Adapter\Cache\Clearer;
use PrestaShop\PrestaShop\Adapter\Configuration;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
Expand All @@ -44,7 +43,6 @@
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Adapter\Tools;
use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManagerBuilder;
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerChain;
use PrestaShopBundle\Event\Dispatcher\NullDispatcher;
use PrestaShopBundle\Service\DataProvider\Admin\CategoriesProvider;
use PrestaShopBundle\Service\DataProvider\Marketplace\ApiClient;
Expand Down Expand Up @@ -113,12 +111,7 @@ public function build()
self::$moduleZipManager,
self::$translator,
new NullDispatcher(),
new CacheClearer(
new CacheClearerChain(),
new Clearer\SymfonyCacheClearer(),
new Clearer\MediaCacheClearer(),
new Clearer\SmartyCacheClearer()
)
new Clearer\SymfonyCacheClearer()
);
}
}
Expand Down
Expand Up @@ -47,7 +47,7 @@ services:
- "@prestashop.module.zip.manager"
- "@translator"
- "@event_dispatcher"
- "@prestashop.adapter.cache_clearer"
- "@prestashop.adapter.cache.clearer.symfony_cache_clearer"

prestashop.module.zip.manager:
class: PrestaShop\PrestaShop\Adapter\Module\ModuleZipManager
Expand Down
5 changes: 2 additions & 3 deletions tests-legacy/Unit/Core/Addon/Module/ModuleManagerTest.php
Expand Up @@ -27,8 +27,8 @@
namespace LegacyTests\Core\Addon\Module;

use PHPUnit\Framework\TestCase;
use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManager;
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface;
use PrestaShopBundle\Event\Dispatcher\NullDispatcher;

class ModuleManagerTest extends TestCase
Expand Down Expand Up @@ -309,8 +309,7 @@ private function mockDispatcher()

private function mockCacheClearer()
{
$this->cacheClearerS = $this->getMockBuilder(CacheClearer::class)
->disableOriginalConstructor()
$this->cacheClearerS = $this->getMockBuilder(CacheClearerInterface::class)
->getMock();
}

Expand Down