Akeeba Backup Core (Akeeba Ltd) + FOF 2.4.3/FOF30 3.3.4/FEF libraries; exact 6.1.1 not publicly downloadable -> deployed files (code only, no backup archives). Signed-off-by: LÁZÁR Imre <imre@illusion.hu> Assisted-by: claude-code@claude-opus-4-8
87 lines
2.1 KiB
PHP
87 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* @package FOF
|
|
* @copyright Copyright (c)2010-2018 Nicholas K. Dionysopoulos / Akeeba Ltd
|
|
* @license GNU GPL version 2 or later
|
|
*/
|
|
|
|
namespace FOF30\Utils;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
/**
|
|
* A utility class to help you quickly clean the Joomla! cache
|
|
*/
|
|
class CacheCleaner
|
|
{
|
|
/**
|
|
* Clears the com_modules and com_plugins cache. You need to call this whenever you alter the publish state or
|
|
* parameters of a module or plugin from your code.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function clearPluginsAndModulesCache()
|
|
{
|
|
self::clearPluginsCache();
|
|
self::clearModulesCache();
|
|
}
|
|
|
|
/**
|
|
* Clears the com_plugins cache. You need to call this whenever you alter the publish state or parameters of a
|
|
* plugin from your code.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function clearPluginsCache()
|
|
{
|
|
self::clearCacheGroups(array('com_plugins'), array(0,1));
|
|
}
|
|
|
|
/**
|
|
* Clears the com_modules cache. You need to call this whenever you alter the publish state or parameters of a
|
|
* module from your code.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function clearModulesCache()
|
|
{
|
|
self::clearCacheGroups(array('com_modules'), array(0,1));
|
|
}
|
|
|
|
/**
|
|
* Clears the specified cache groups.
|
|
*
|
|
* @param array $clearGroups Which cache groups to clear. Usually this is com_yourcomponent to clear your
|
|
* component's cache.
|
|
* @param array $cacheClients Which cache clients to clear. 0 is the back-end, 1 is the front-end. If you do not
|
|
* specify anything, both cache clients will be cleared.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function clearCacheGroups(array $clearGroups, array $cacheClients = array(0, 1))
|
|
{
|
|
$conf = \JFactory::getConfig();
|
|
|
|
foreach ($clearGroups as $group)
|
|
{
|
|
foreach ($cacheClients as $client_id)
|
|
{
|
|
try
|
|
{
|
|
$options = array(
|
|
'defaultgroup' => $group,
|
|
'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache')
|
|
);
|
|
|
|
$cache = \JCache::getInstance('callback', $options);
|
|
$cache->clean();
|
|
}
|
|
catch (\Exception $e)
|
|
{
|
|
// suck it up
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|