Skip to content

Instantly share code, notes, and snippets.

@cam8001
Last active April 15, 2019 19:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cam8001/1925886 to your computer and use it in GitHub Desktop.
Save cam8001/1925886 to your computer and use it in GitHub Desktop.
Feature revert library function
<?php
/**
* Completely reverts a feature based on the settings in its .info file.
*
* @param string $feature_module
* Name of feature/module to revert.
*/
function full_feature_revert($feature_module) {
$info = drupal_parse_info_file(drupal_get_path('module', $feature_module) . '/' . $feature_module . '.info');
$revert = array(
$feature_module => array_keys($info['features']),
);
watchdog('full_feature_revert', 'Reverting feature @feature on behalf of @function', array('@feature' => $feature_module, '@function' => _calling_function()));
features_revert($revert);
}
/**
* Get the name of the function that called your function.
*
* @return string
* Name of function.
*/
function _calling_function() {
$trace = debug_backtrace();
return $trace[2]['function'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment