Created
October 27, 2013 13:44
-
-
Save gibbs/7182293 to your computer and use it in GitHub Desktop.
Refresh / clear the MODx Revolution (2.0.*) cache
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 | |
/* | |
* 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