Question

So I looked at the features API, and in order to enable a feature, they use this code:

function hook_pre_features_enable_feature($component){
};

So I go in and add this:

function mysite_pre_features_enable_feature($component){
    $component = 'roles';
};

My Feature is already there, but it never gets enabled. Why is this?

Was it helpful?

Solution

in order to enable a feature, they use this code

That's not accurate. The hook function is actually:

Invoked on a Feature module before that module is enabled.

It's not involved with the action of enabling the feature, it's just a listener to enable it to run some code just before something else enables it.

Features are just modules, and to enable one you use the same method as if you were just enabling a module:

module_enable(['foo']);
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top