Created
October 2, 2013 06:05
-
-
Save enminc/6789706 to your computer and use it in GitHub Desktop.
Simple utility script to remove all undesired context and associated resources from modx db
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
$dontRem = array('web','mgr'); /* add any additional context you dont wish to have removed here */ | |
$contexts = $modx->getCollection('modContext'); | |
foreach($contexts as $ctx){ | |
$key = $ctx->get('key'); | |
if(!in_array($key,$dontRem)) { | |
$response = $modx->runProcessor('context/remove',array('key'=>$key)); | |
if ($response->isError()) { | |
echo $response->getMessage() . '<hr/>'; | |
} | |
else{ | |
echo "removed $key"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment