How to use the Features API to enable a feature?
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']);