Created
February 27, 2012 14:22
-
-
Save pepebe/1924151 to your computer and use it in GitHub Desktop.
MODx: REFRESH / CLEAR MODX (REVOLUTION) CACHE FROM PHP SCRIPT REFRESH / CLEAR MODX (REVOLUTION) CACHE FROM PHP SCRIPT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment