Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After using Flag Abuse and configuring the flags embedded in the module, I noticed it is impossible to export them in a feature (see #2284353: Features compatibility ). Is there a reason why flags defined in hook_flag_default_flags() cannot be exported in a feature? What could be done to correct this behaviour?
Currently, we are forced to duplicate these flags. The aforementioned issue goes as far as suggesting to create flags during installation instead of using hook_flag_default_flags(), which somehow makes sense, but defeats the whole purpose of this hook...
Comments
Comment #2
joachim CreditAttribution: joachim commentedThat is a standard problem with all modules that export configuration to Features and also provide their own defaults. The two things are provided by the same system: when you create a feature, you are writing a module with its own hook_flag_default_flags().
There's a module for altering features, which I've not used, but which might do what you want. Alternatively, you could implement the flag alter hook yourself and tweak the flag in code.
Comment #3
FMB CreditAttribution: FMB commentedOK joachim, thanks for your answer.
Comment #4
FMB CreditAttribution: FMB commentedIt then seems that creating flags during installation like suggested in #2284353: Features compatibility is a better solution, so that
hook_flag_default_flags()
is reserved for exporting in features. According to my tests, current installations would not be affected by the removal of this hook. Would you confirm this is safe? Thanks in advance.Comment #5
FMB CreditAttribution: FMB commentedFlags defined in this hook are created in the database the first time it is called, therefore it is safe to delete it.