Skip to content
Extraits de code Groupes Projets
Valider f9a476a9 rédigé par JamesRezo's avatar JamesRezo :tada:
Parcourir les fichiers

feat: assets clear cache at install/update

parent cf2f6432
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!7Asset clear cache
<?php
namespace Spip\Composer;
use Composer\Script\Event;
use Symfony\Component\Filesystem\Filesystem;
/**
* Script for post-install-cmd and post-update-cmd.
*/
class AssetsClearCache
{
/** @var string[] */
private static array $dirs = [
'cache-css',
'cache-js',
];
/**
* To delete the cache files dedicated for public compiled assets
*
* @param $event
*
* @return void
*/
public static function assetsClearCache(Event $event)
{
$event->getIO()->write('Clearing the assets cache ...');
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir') . '/';
$f = new Filesystem;
foreach (self::$dirs as $dir) {
$toDelete = $vendorDir . '../' . SpipPaths::VAR . '/' . $dir;
if ($f->exists($toDelete)) {
$f->remove($toDelete);
}
}
$event->getIO()->write('Done.');
}
}
......@@ -28,8 +28,8 @@ class SpipInstallerPlugin implements PluginInterface, EventSubscriberInterface,
public static function getSubscribedEvents()
{
return [
'post-install-cmd' => [['updateSafetyScreen'], ['pluginsClearCache']],
'post-update-cmd' => [['updateSafetyScreen'], ['pluginsClearCache']],
'post-install-cmd' => [['updateSafetyScreen'], ['clearCache']],
'post-update-cmd' => [['updateSafetyScreen'], ['clearCache']],
];
}
......@@ -38,9 +38,10 @@ class SpipInstallerPlugin implements PluginInterface, EventSubscriberInterface,
Security::copySafetyScreen($event);
}
public function pluginsClearCache(Event $event): void
public function clearCache(Event $event): void
{
PluginsClearCache::pluginClearCache($event);
AssetsClearCache::assetsClearCache($event);
}
public function getCapabilities()
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter