Skip to content

Add a priority for hooks #5889

@nikophil

Description

@nikophil

Hello,

would you accept a PR which would add a concept of "priority" between hooks like Before, After...?

This would allow to control the order of execution of these hooks, mainly useful when used along with traits:

trait SomeTraitWithHook
{
	#[Before]
	protected function someBeforeHook(): void
    {
		// do something
    }
}

trait SomeOtherTraitWithHook
{
	#[Before(priority: 5)]
	protected function someOtherBeforeHook(): void
    {
		// will be executed before `SomeTraitWithHook::someBeforeHook`
    }
}

priority should be any integer (even negative ones), and it would default to 0.

thanks for your answer on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions