Skip to content

Instantly share code, notes, and snippets.

@ethanhinson
Created November 13, 2013 00:03
Show Gist options
  • Save ethanhinson/7441065 to your computer and use it in GitHub Desktop.
Save ethanhinson/7441065 to your computer and use it in GitHub Desktop.
<?php
/**
* Revert specified features.
*
* @TODO Check that it really is Forced features revert. Currently an exact
* copy of the function initially placed in feature_projects.install.
*
* Code mostly taken from drush.
*/
function vrweb_base_features_revert($modules) {
module_load_include('inc', 'features', 'features.export');
features_include();
foreach ($modules as $module) {
if (($feature = feature_load($module, TRUE)) && module_exists($module)) {
$components = array();
// Forcefully revert all components of a feature.
foreach (array_keys($feature->info['features']) as $component) {
if (features_hook($component, 'features_revert')) {
$components[] = $component;
}
}
}
foreach ($components as $component) {
features_revert(array($module => array($component)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment