Skip to content

Instantly share code, notes, and snippets.

@becw
Last active March 26, 2019 06:53
Show Gist options
  • Save becw/4121388 to your computer and use it in GitHub Desktop.
Save becw/4121388 to your computer and use it in GitHub Desktop.
Enable/revert a feature in a Drupal update hook #drupal7
/**
* EXAMPLE FEATURE UPDATE
* Enable and revert the my_new_feature_name feature.
*/
function example_update_7001() {
// An array of new or changed features; the array keys are feature names,
// values are an array of exportable types as seen in a feature's .info file:
// features[field][] = node-page-body
$features = array(
'my_new_feature_name' => array('field', 'variable'),
'my_other_feature' => array('taxonomy'),
);
// Enable the modules by name.
module_enable(array_keys($features));
// Revert the features (if the feature has been changed)
features_revert($features);
return t('Enabled the my_new_feature_name and my_other_feature features.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment