function flag_features_revert in Flag 7.3
Same name and namespace in other branches
- 6.2 includes/flag.features.inc \flag_features_revert()
- 7.2 includes/flag.features.inc \flag_features_revert()
Implements hook_features_revert().
Parameters
string $module: The name of module for which to revert content.
File
- includes/
flag.features.inc, line 77 - Features integration for Flag module.
Code
function flag_features_revert($module = NULL) {
// Get default flags from features.
if (module_hook($module, 'flag_default_flags')) {
module_load_include('inc', 'flag', '/includes/flag.admin');
$default_flags = module_invoke($module, 'flag_default_flags');
// Build up values for the cache clear.
$entity_types = array();
// Revert flags that are defined in code.
foreach ($default_flags as $flag_name => $flag_info) {
if (is_numeric($flag_name)) {
// Backward compatibility.
$flag_name = $flag_info['name'];
}
$flag = flag_load($flag_name, TRUE);
if ($flag && $flag
->revert() === FALSE) {
drupal_set_message(t('Could not revert flag %flag-name to the state described in your code: Your flag was created by a different version of the Flag module than is now being used.', array(
'%flag-name' => $flag->name,
)), 'error');
}
$entity_types[] = $flag->entity_type;
}
_flag_clear_cache($entity_types);
}
}