Closed (fixed)
Project:
Features
Version:
6.x-1.0-beta10
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Jul 2010 at 18:57 UTC
Updated:
12 Aug 2010 at 21:20 UTC
I've been going over the example code in features.api.php to see what I need to change, and had some questions.
Where the example code refers to "mycomponent_defaults" - that is meant to be the default_hook value for the component, yes? Is there a way to get that string from the component definition instead of having it hardcoded in multiple places?
In the revert hook example, it makes a direct call to module_invoke_all($module_name, 'mycomponent_defaults');. Is there a reason to do that vs a call to features_get_default('mycomponent', $module_name)?
Thanks!
Comments
Comment #1
yhahn commentedYes, that is the default hook. In terms of redundancy, I'm assuming you're referring to the return value of
hook_features_export_render(). This is a change we could make in the next version of the API, but at the moment the explicit declaration of the defaults hook inhook_features_export_render()gives you the additional flexibility of writing more that one function if you were to need them.Yes, if your component has been written into include files by Features you will want to use
features_get_default('mycomponent', $module_name). It is more or less equivalent to doing this:Comment #2
brad.bulger commentedabout the default_hook value - the explicit use of the hook name in the render function makes sense, for the reasons you say. i meant more the redundancy in my own module's code. if for some odd reason i change the value of "default_hook" in the component declaration, i would have to go change the string where it appears elsewhere. looking through the features code, it seems like i could make a call to
features_get_default_hooks()to avoid that:or just use a constant or some such. this is a very minor thing. mostly about making clear what the string is and where it comes from.
the question about how to get defaults in the revert() hook function came up because i was getting FALSE, but i see now that's because module_name and component swapped places in the call. so just my bug.
thanks for the quick response!