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 new "callable" extension class #1

Merged
merged 2 commits into from
Feb 28, 2024
Merged

Add a new "callable" extension class #1

merged 2 commits into from
Feb 28, 2024

Conversation

M1ke
Copy link
Member

@M1ke M1ke commented Feb 28, 2024

This extension allows a custom callable, making it simpler for clients to do ad-hoc extensions in local scope without having to make specific extension classes for each use case.

For example a client could wrap their own container for the Sentry class, and set context on this as a user progresses through a flow. At the time an exception is handled they want current context passed in. They could set this up in advance using the callable extension like so:

$fn_release = static function (Event $event): void{
  $event->release = $event->release ?: self::getRelease();
};

return new CallableExtension($fn_release);

So the initial setup saves this extension, but if the context (in this case static context, for cross-cutting concerns) has new data by the time the stack is processed, the callable extension pulls that in.

(Originally at kodus/sentry#9)

@M1ke M1ke merged commit bc675e5 into master Feb 28, 2024
5 checks passed
@M1ke M1ke deleted the callable-extension branch February 28, 2024 11:04
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.

1 participant