In another module's implementation of hook_features_export_alter(), I'd like to be able to add attributes to my exported user roles. But currently features.user.inc implements its own custom hook_features_export_render() which hardcodes a single value into the exported object.

The attached patch changes the structure of the $export array produced by user_role_features_export() so that the exported data is a keyed array instead of just a single string, and changes user_role_features_export_render() to render the array contents rather than creating its own single-value array inside. The actual rendered output of user_role_features_export_render() is not affected unless another module implements hook_features_export_alter() and changes the $export['features']['user_role'] array contents.

CommentFileSizeAuthor
features-user_role-attributes-00.diff914 bytessmokris

Comments

smokris’s picture

Status: Needs review » Needs work

Hmm. When checking Features status, the $data that gets passed to user_role_features_export_render() is different — it isn't first passed through hook_features_export_alter(). So using hook_features_export_alter() to add user role data results in permanently-overridden features.

Apparently hook_features_export_alter() is only capable of cleanly removing Features Components, not modifying them?

hefox’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Export is for editing what becomes the .info file and tells features what to export, not the actual data being rendered.

There's a few other issues about changing the rendering process so it's easier to hook into it, so this is likely a duplicate of them. (Don't recall which ones).

Feature requests need to go into 7.x

smokris’s picture

Ah, I see. Better documentation of what that hook is and isn't for would be helpful — I branched this issue to #1438212: Improve documentation for hook_features_export_alter().

smokris’s picture

Status: Needs work » Closed (works as designed)

Also, I'll close this issue and await decision on the rendering process changes.