Problem/Motivation

To add a feature to the ignore list, the module needs to be hacked/patched to take the new feature into account.

Adding a hook to the module would allow site developer to add features to the exclude list while keeping the module code as standard allowing for possible future updates.

Also, module creators could implement the hook to exclude their own test / example features.

Proposed resolution

  • Add the hook call.
  • Create an api file to document the hook.
  • Use the hook to set the default exclusions. (optional)

Comments

John Cook created an issue. See original summary.

john cook’s picture

Status: Active » Needs review
StatusFileSize
new2.06 KB

I've created a patch that implements a hook, namely hook_features_hide().

The hook's documentation is in features_hide.api.php and I used the hook to get the default features to hide array.

john cook’s picture

Issue summary: View changes
molenick’s picture

Hello, thanks for this patch - I agree that this is a great enhancement for this project. I'll take some time to review this in the next week and if all is good, I'll merge it in.

Thanks!

molenick’s picture

This looks pretty good, but I have one minor thing I'd like to change. With this patch, I'm able to add entries like so:

/**
 * Implements hook_features_hide().
 */
function MYMODULE_features_hide() {
  return 'MYMODULE_feature';
}

This is great, but I think it'd also be useful to allow developers to remove items from the list as well. To do that, I think we'd need to switch from module_invoke_all() to drupal_alter() to allow something like this:

/**
 * Implements hook_features_hide().
 */
function MYMODULE_features_hide(&$hide_list) {
  // Remove an item.
  unset($hide_list['MYMODULE_showfeature']);
  // Add an item.
  $hide_list['MYMODULE_hidefeature'] = 'MYMODULE_hidefeature';
}

That's the basic gist, the structure of the $hide_list might need working out a bit though.

john cook’s picture

StatusFileSize
new2.67 KB
new1.4 KB

I've added an alter hook, hook_features_hide_alter() so that items added to the list can be removed if necessary.

The hooks are run in the following order:

  1. hook_features_hide()
  2. hook_features_hide_alter()

This allows all modules to have their addition done before the alter is run, otherwise if there were two modules (one added a feature and the other removed the same feature) whether the feature would be shown or not is undefined as then it comes down to the order the modules are loaded.

  • molenick committed 2955d6e on 7.x-1.x authored by John Cook
    Issue #2684979 by John Cook: Add hook for changing features to ignore
    
  • molenick committed 935d164 on 7.x-1.x authored by John Cook
    Issue #2684979 by John Cook: Add hook_features_hide_alter.
    
molenick’s picture

Hi John,

Thanks again for for this contribution! I've gone ahead and committed your additions, the 7.x-1.x dev release and 7.x-1.1 (which should be up shortly) contain these.

Best,
Matt

molenick’s picture

Status: Needs review » Closed (fixed)