Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "boot" phase #192

Merged
merged 21 commits into from
Dec 19, 2024
Merged

Add a "boot" phase #192

merged 21 commits into from
Dec 19, 2024

Conversation

DanielCoulbourne
Copy link
Contributor

Adds a mount phase which happens before auth and validate.

This phase can be used to set up event props, etc.

Useful if you want to register custom attributes that modify properties like so:

class SomeEvent extends Event
{
    #[NowIfNull] // We can register a listener on the mount hook that sets this to now() if it is not passed.
    public ?Carbon $when_did_the_thing_happen = null;
}

Copy link
Contributor

@inxilpro inxilpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call it boot or construct instead of mount?

src/Lifecycle/Dispatcher.php Outdated Show resolved Hide resolved
examples/Bank/src/Events/AccountOpened.php Outdated Show resolved Hide resolved
@joshhanley
Copy link
Collaborator

Would it also run when an event is replayed? If so, then I think boot() would be better

@inxilpro
Copy link
Contributor

Reviewed with Daniel. We need to address the differences between this and #145 but otherwise looks good.

@inxilpro inxilpro changed the title Add a "Mount" phase Add a "boot" phase Dec 19, 2024
@inxilpro inxilpro merged commit d83543b into main Dec 19, 2024
@inxilpro inxilpro deleted the add-firing-phase branch December 19, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants