From 5f8aad1a028a257fd1f1207e55a6a37e5541350f Mon Sep 17 00:00:00 2001 From: Toby Twigger Date: Mon, 6 Dec 2021 15:03:47 +0000 Subject: [PATCH 1/2] Merge previously defined view data when building the view mailable data --- src/ExtractsMailableTags.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ExtractsMailableTags.php b/src/ExtractsMailableTags.php index 569c7b5c0..0fac391a3 100644 --- a/src/ExtractsMailableTags.php +++ b/src/ExtractsMailableTags.php @@ -14,12 +14,16 @@ trait ExtractsMailableTags */ protected static function registerMailableTagExtractor() { - Mailable::buildViewDataUsing(function ($mailable) { - return [ + $existingCallback = Mailable::$viewDataCallback; + + Mailable::buildViewDataUsing(function ($mailable) use ($existingCallback) { + $existingData = $existingCallback ? call_user_func( $existingCallback, $mailable ) : []; + + return array_merge($existingData, [ '__telescope' => ExtractTags::from($mailable), '__telescope_mailable' => get_class($mailable), '__telescope_queued' => in_array(ShouldQueue::class, class_implements($mailable)), - ]; + ]); }); } } From 213ff69767bc7168f62115a6cc86b17123d7bed6 Mon Sep 17 00:00:00 2001 From: Toby Twigger Date: Mon, 6 Dec 2021 15:13:38 +0000 Subject: [PATCH 2/2] Code style change for CI --- src/ExtractsMailableTags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExtractsMailableTags.php b/src/ExtractsMailableTags.php index 0fac391a3..b39ce6a4d 100644 --- a/src/ExtractsMailableTags.php +++ b/src/ExtractsMailableTags.php @@ -17,7 +17,7 @@ protected static function registerMailableTagExtractor() $existingCallback = Mailable::$viewDataCallback; Mailable::buildViewDataUsing(function ($mailable) use ($existingCallback) { - $existingData = $existingCallback ? call_user_func( $existingCallback, $mailable ) : []; + $existingData = $existingCallback ? call_user_func($existingCallback, $mailable) : []; return array_merge($existingData, [ '__telescope' => ExtractTags::from($mailable),