Drupal - Revert a Feature Component programmatically

Here are a few thoughts though on resetting your features programmatically or as add-on install scripts.

You could use Drush to reset the Feature:

drush features-revert [feature name]

Another thought would be to use features_revert() during the install process:

features_revert(array('module' => array('component')));

The Strongarm module could be useful as well to force your Feature to retain its default state I think.

I have to agree with @Letharion in his comment on your OP. I would want to know that other important things aren't being mistakenly modified during the install process.

You can revert a single features module with features_revert_module().


Revert ALL components in feature

$feature = features_get_features('my_feature_machine_name');
$components = array_keys($feature->info['features']);
features_revert(array('my_feature_machine_name' => $components));