-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new variables * Repair tests Co-authored-by: Hubert Krzysztofiak <[email protected]>
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace EscolaLms\TemplatesEmail\Cart; | ||
|
||
use EscolaLms\Cart\Models\Order; | ||
use EscolaLms\Core\Models\User; | ||
use EscolaLms\Templates\Events\EventWrapper; | ||
|
||
class OrderCreatedVariables extends CartVariables | ||
{ | ||
const VAR_USER_NAME = '@VarUserName'; | ||
|
||
public static function mockedVariables(?User $user = null): array | ||
{ | ||
$faker = \Faker\Factory::create(); | ||
return array_merge(parent::mockedVariables(), [ | ||
self::VAR_USER_NAME => $faker->name(), | ||
]); | ||
} | ||
|
||
public static function variablesFromEvent(EventWrapper $event): array | ||
{ | ||
return array_merge(parent::variablesFromEvent($event), [ | ||
self::VAR_USER_NAME => $event->getUser()->name | ||
]); | ||
} | ||
|
||
public static function assignableClass(): ?string | ||
{ | ||
return Order::class; | ||
} | ||
|
||
public static function requiredVariables(): array | ||
{ | ||
return [ | ||
self::VAR_USER_NAME, | ||
]; | ||
} | ||
|
||
public static function requiredVariablesInSection(string $sectionKey): array | ||
{ | ||
return []; | ||
} | ||
|
||
public static function defaultSectionsContent(): array | ||
{ | ||
return [ | ||
'title' => __('Thank you for your order'), | ||
'content' => self::wrapWithMjml(__('<h1>Hello :user_name!</h1><p>Thanks for your order.</p>', [ | ||
'user_name' => self::VAR_USER_NAME | ||
])), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters