Skip to content

Instantly share code, notes, and snippets.

@enminc
Created October 2, 2013 06:05
Show Gist options
  • Save enminc/6789706 to your computer and use it in GitHub Desktop.
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
$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