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

Merge previously defined view data when building the view mailable data #1157

Merged
merged 2 commits into from
Dec 6, 2021
Merged

Merge previously defined view data when building the view mailable data #1157

merged 2 commits into from
Dec 6, 2021

Conversation

tobytwigger
Copy link
Contributor

@tobytwigger tobytwigger commented Dec 6, 2021

Hi! 👋

In a project I manage, in which we use Telescope, we also have set up functionality to record any sent emails in the database using the Illuminate\Mail\Mailable::buildViewDataUsing() callback to pass the payload to the MessageSending or MessageSent events.

When we have Telescope enabled, we find that this functionality breaks. This is because when Telescope starts it registers its own data to build up views with, and therefore overwrites our mailable data. For reference, this is where we define our own mailable data: https://github.com/bristol-su/portal-mail/blob/develop/src/MailServiceProvider.php#L89

This PR retrieves the current callback during the start function, and then if it isn't empty calls it when building View data and merges the result with Telescopes view data. This won't lead to any breaking changes since all the Telescope data is still present and prioritised over existing data, but will allow telescope users to still use the overriding view data feature.

@taylorotwell taylorotwell merged commit 793c3e3 into laravel:4.x Dec 6, 2021
@taylorotwell
Copy link
Member

Thanks for contributing to Laravel! ❤️

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.

2 participants