Skip to content

[Feature Request]: Fire an event when building with a generic hook name to be able to target it easily  #47

Description

@luislard

Is your feature request related to a problem?

Currently, the only way to add modules from other places is via adding an action to this hook

The hook name is created dynamically based on the package name.

Since #44 was merged it would be very nice to have a way to add a module with an extension to all packages automatically.

So, in a project with many packages we could do:

add_action('inpsyde.modularity.package.init', fn($package) => $package->addModule($moduleWithExtensionByType));

Describe the desired solution

Maybe the solution is to add a hook.

Describe the alternatives that you have considered

Option 1:
Adding a generic hook

Option 2:
Using current hookName is also an option but you should hook in another hook like

function addExtensionCb (){
    /* some logic parsing current_action() name with startsWith inpsyde.modularity and endWith init */
}

add_action('muplugins_loaded', function(){
    add_action('all', 'addExtensionCb');
}, PHP_INT_MIN);

add_action('plugins_loaded', function(){
    remove_action('all', 'addExtensionCb');
}, PHP_INT_MAX)

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions