Skip to content

Commit

Permalink
emails for deleting user submissions (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: dawid.miklas <[email protected]>
  • Loading branch information
dicani0 and dawid.miklas authored Apr 27, 2023
1 parent 1183c3c commit 8f3761e
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/AssignWithoutAccount/UnassignProductVariables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace EscolaLms\TemplatesEmail\AssignWithoutAccount;

use EscolaLms\Core\Models\User;
use EscolaLms\Templates\Events\EventWrapper;
use EscolaLms\TemplatesEmail\Core\EmailVariables;

class UnassignProductVariables extends EmailVariables
{
const VAR_PRODUCT_NAME = "@VarProductName";

public static function mockedVariables(?User $user = null): array
{
$faker = \Faker\Factory::create();
return array_merge(parent::mockedVariables($user), [
self::VAR_PRODUCT_NAME => $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 [];
}
}
58 changes: 58 additions & 0 deletions src/AssignWithoutAccount/UnassignProductableVariables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace EscolaLms\TemplatesEmail\AssignWithoutAccount;

use EscolaLms\Core\Models\User;
use EscolaLms\Templates\Events\EventWrapper;
use EscolaLms\TemplatesEmail\Core\EmailVariables;

class UnassignProductableVariables extends EmailVariables
{
const VAR_PRODUCTABLE_NAME = "@VarProductableName";

public static function mockedVariables(?User $user = null): array
{
$faker = \Faker\Factory::create();
return array_merge(parent::mockedVariables($user), [
self::VAR_PRODUCTABLE_NAME => $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 [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}

0 comments on commit 8f3761e

Please sign in to comment.