MODx: REFRESH / CLEAR MODX (REVOLUTION) CACHE FROM PHP SCRIPT REFRESH / CLEAR MODX (REVOLUTION) CACHE FROM PHP SCRIPT
<?php
/* Downloaded from: http://www.dangibbs.co.uk/journal/clear-modx-revolution-cache-from-php-script
UNTESTED!!!
*/
/*
* Clear (refresh) MODx Cache from external PHP Script
*
* MODx Revolution (2.0.7-pl)
* Daniel Gibbs
*/
// Path to MODx Core Directory
define("MODX_CORE_PATH", "../core/");
define("MODX_CONFIG_KEY", "config");
// Include MODx main class
include(MODX_CORE_PATH."model/modx/modx.class.php");
// Instantiate
$modx= new modX();
$modx->initialize("xPDO");
// Clear the cache (taken from /core/model/modx/processors/system/clearcache.php)
$paths = array(
'config.cache.php',
'sitePublishing.idx.php',
'registry/mgr/workspace/',
'lexicon/',
);
$contexts = $modx->getCollection('modContext');
foreach ($contexts as $context) {
$paths[] = $context->get('key') . '/';
}
$options = array(
'publishing' => 1,
'extensions' => array('.cache.php', '.msg.php', '.tpl.php'),
);
if ($modx->getOption('cache_db')) $options['objects'] = '*';
// The final magic
$results= $modx->cacheManager->clearCache($paths, $options);