From 8f3761e69cc06cc63e1f3a652383141203c18481 Mon Sep 17 00:00:00 2001 From: Dawid Miklas <58490533+dicani0@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:36:18 +0200 Subject: [PATCH] emails for deleting user submissions (#73) Co-authored-by: dawid.miklas --- .../UnassignProductVariables.php | 58 +++++++++++++++++++ .../UnassignProductableVariables.php | 58 +++++++++++++++++++ ...utAccountTemplatesEventServiceProvider.php | 15 +++++ 3 files changed, 131 insertions(+) create mode 100644 src/AssignWithoutAccount/UnassignProductVariables.php create mode 100644 src/AssignWithoutAccount/UnassignProductableVariables.php diff --git a/src/AssignWithoutAccount/UnassignProductVariables.php b/src/AssignWithoutAccount/UnassignProductVariables.php new file mode 100644 index 0000000..9d3e29a --- /dev/null +++ b/src/AssignWithoutAccount/UnassignProductVariables.php @@ -0,0 +1,58 @@ + $faker->word, + ]); + } + + public static function variablesFromEvent(EventWrapper $event): array + { + return array_merge(parent::variablesFromEvent($event), [ + self::VAR_PRODUCT_NAME => $event->getProduct()->name, + ]); + } + + public static function defaultSectionsContent(): array + { + return [ + 'title' => '', + 'content' => '' + ]; + } + + public static function assignableClass(): ?string + { + return null; + } + + public static function requiredVariables(): array + { + return [ + self::VAR_PRODUCT_NAME + ]; + } + + public static function requiredVariablesInSection(string $sectionKey): array + { + if ($sectionKey === 'content') { + return [ + self::VAR_PRODUCT_NAME, + ]; + } + + return []; + } +} diff --git a/src/AssignWithoutAccount/UnassignProductableVariables.php b/src/AssignWithoutAccount/UnassignProductableVariables.php new file mode 100644 index 0000000..66f8c29 --- /dev/null +++ b/src/AssignWithoutAccount/UnassignProductableVariables.php @@ -0,0 +1,58 @@ + $faker->word, + ]); + } + + public static function variablesFromEvent(EventWrapper $event): array + { + return array_merge(parent::variablesFromEvent($event), [ + self::VAR_PRODUCTABLE_NAME => $event->getProductable()->getName(), + ]); + } + + public static function defaultSectionsContent(): array + { + return [ + 'title' => '', + 'content' => '' + ]; + } + + public static function assignableClass(): ?string + { + return null; + } + + public static function requiredVariables(): array + { + return [ + self::VAR_PRODUCTABLE_NAME + ]; + } + + public static function requiredVariablesInSection(string $sectionKey): array + { + if ($sectionKey === 'content') { + return [ + self::VAR_PRODUCTABLE_NAME, + ]; + } + + return []; + } +} diff --git a/src/Providers/AssignWithoutAccountTemplatesEventServiceProvider.php b/src/Providers/AssignWithoutAccountTemplatesEventServiceProvider.php index 6661336..e0a233d 100644 --- a/src/Providers/AssignWithoutAccountTemplatesEventServiceProvider.php +++ b/src/Providers/AssignWithoutAccountTemplatesEventServiceProvider.php @@ -4,9 +4,13 @@ use EscolaLms\AssignWithoutAccount\Events\AssignToProduct; use EscolaLms\AssignWithoutAccount\Events\AssignToProductable; +use EscolaLms\AssignWithoutAccount\Events\UnassignProduct; +use EscolaLms\AssignWithoutAccount\Events\UnassignProductable; use EscolaLms\Templates\Facades\Template; use EscolaLms\TemplatesEmail\AssignWithoutAccount\AssignToProductableVariables; use EscolaLms\TemplatesEmail\AssignWithoutAccount\AssignToProductVariables; +use EscolaLms\TemplatesEmail\AssignWithoutAccount\UnassignProductableVariables; +use EscolaLms\TemplatesEmail\AssignWithoutAccount\UnassignProductVariables; use EscolaLms\TemplatesEmail\Core\EmailChannel; use Illuminate\Foundation\Support\Providers\EventServiceProvider; @@ -25,5 +29,16 @@ public function boot() EmailChannel::class, AssignToProductableVariables::class ); + + Template::register( + UnassignProduct::class, + EmailChannel::class, + UnassignProductVariables::class + ); + + Template::register( + UnassignProductable::class, + EmailChannel::class, + UnassignProductableVariables::class); } }