Skip to content

Commit

Permalink
Merge pull request #33 from EscolaLMS/feature/STAR-40
Browse files Browse the repository at this point in the history
Feature/star 40
  • Loading branch information
HerbertIV authored Mar 23, 2022
2 parents cf7b358 + 2c411dd commit e53009a
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 21 deletions.
13 changes: 8 additions & 5 deletions src/Consultations/ApprovedTermVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

class ApprovedTermVariables extends CommonConsultationVariables
{
const VAR_COURSE_DEADLINE = '@VarApprovedTerm';

// TODO Add variable to emails
public static function defaultSectionsContent(): array
{
return [
'title' => '',
'content' => ''
'title' => __('Approved term ":consultation"', [
'consultation' => self::VAR_CONSULTATION_TITLE,
]),
'content' => self::wrapWithMjml(__('<h1>Hello :user_name!</h1><p>Reported term :proposed_term for consultation ":consultation" was approved.</p>', [
'user_name' => self::VAR_USER_NAME,
'consultation' => self::VAR_CONSULTATION_TITLE,
'proposed_term' => self::VAR_CONSULTATION_PROPOSED_TERM
]),),
];
}
}
19 changes: 13 additions & 6 deletions src/Consultations/CommonConsultationVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,46 @@
abstract class CommonConsultationVariables extends EmailVariables
{
const VAR_USER_NAME = '@VarUserName';
const VAR_COURSE_TITLE = '@VarCourseTitle';
const VAR_CONSULTATION_TITLE = '@VarConsultationTitle';
const VAR_CONSULTATION_PROPOSED_TERM = '@VarConsultationProposedTerm';



public static function mockedVariables(?User $user = null): array
{
$faker = \Faker\Factory::create();
return array_merge(parent::mockedVariables(), [
self::VAR_USER_NAME => $faker->name(),
self::VAR_COURSE_TITLE => $faker->word(),
self::VAR_CONSULTATION_TITLE => $faker->word(),

]);
}

public static function variablesFromEvent(EventWrapper $event): array
{
return array_merge(parent::variablesFromEvent($event), [
self::VAR_USER_NAME => $event->getUser()->name,
self::VAR_COURSE_TITLE => $event->getCourse()->title,
self::VAR_CONSULTATION_TITLE => $event->getConsultationTerm()->consultation->name,
self::VAR_CONSULTATION_PROPOSED_TERM => $event->getConsultationTerm()->executed_at,
]);
}

public static function requiredVariables(): array
{
return [
self::VAR_USER_NAME,
self::VAR_COURSE_TITLE,
self::VAR_CONSULTATION_TITLE,
self::VAR_CONSULTATION_PROPOSED_TERM,
];
}

public static function requiredVariablesInSection(string $sectionKey): array
{
if ($sectionKey === 'content') {
[
return [
self::VAR_USER_NAME,
self::VAR_COURSE_TITLE,
self::VAR_CONSULTATION_TITLE,
self::VAR_CONSULTATION_PROPOSED_TERM,
];
}
return [];
Expand Down
13 changes: 8 additions & 5 deletions src/Consultations/RejectTermVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

class RejectTermVariables extends CommonConsultationVariables
{
const VAR_COURSE_DEADLINE = '@VarRejectTerm';

// TODO Add variable to emails
public static function defaultSectionsContent(): array
{
return [
'title' => '',
'content' => ''
'title' => __('Reject term ":consultation"', [
'consultation' => self::VAR_CONSULTATION_TITLE,
]),
'content' => self::wrapWithMjml(__('<h1>Hello :user_name!</h1><p>Reported term :proposed_term for consultation ":consultation" was rejected.</p>', [
'user_name' => self::VAR_USER_NAME,
'consultation' => self::VAR_CONSULTATION_TITLE,
'proposed_term' => self::VAR_CONSULTATION_PROPOSED_TERM
]),),
];
}
}
40 changes: 36 additions & 4 deletions src/Consultations/ReportTermVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,48 @@

namespace EscolaLms\TemplatesEmail\Consultations;

use EscolaLms\Templates\Events\EventWrapper;

class ReportTermVariables extends CommonConsultationVariables
{
const VAR_COURSE_DEADLINE = '@VarReportTerm';
const VAR_CONSULTATION_BUYER_NAME = '@VarConsultationBuyerName';

public static function requiredVariables(): array
{
return array_merge(parent::requiredVariables(), [
self::VAR_CONSULTATION_BUYER_NAME,
]);
}

public static function requiredVariablesInSection(string $sectionKey): array
{
if ($sectionKey === 'content') {
return array_merge(parent::requiredVariablesInSection($sectionKey), [
self::VAR_CONSULTATION_BUYER_NAME,
]);
}
return [];
}

public static function variablesFromEvent(EventWrapper $event): array
{
return array_merge(parent::variablesFromEvent($event), [
self::VAR_CONSULTATION_BUYER_NAME => $event->getConsultationTerm()->orderItem->order->user->name,
]);
}

// TODO Add variable to emails
public static function defaultSectionsContent(): array
{
return [
'title' => '',
'content' => ''
'title' => __('Report term ":consultation"', [
'consultation' => self::VAR_CONSULTATION_TITLE,
]),
'content' => self::wrapWithMjml(__('<h1>Hello :user_name!</h1><p>Buyer :consultation_buyer_name consultation ":consultation" reported proposed term realization: :proposed_term.</p>', [
'user_name' => self::VAR_USER_NAME,
'consultation_buyer_name' => self::VAR_CONSULTATION_BUYER_NAME,
'consultation' => self::VAR_CONSULTATION_TITLE,
'proposed_term' => self::VAR_CONSULTATION_PROPOSED_TERM
]),),
];
}
}
2 changes: 1 addition & 1 deletion src/EscolaLmsTemplatesEmailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use EscolaLms\TemplatesEmail\Providers\AssignWithoutAccountTemplatesEventServiceProvider;
use EscolaLms\TemplatesEmail\Providers\AuthTemplatesEventServiceProvider;
use EscolaLms\TemplatesEmail\Providers\AuthTemplatesServiceProvider;
use EscolaLms\TemplatesEmail\Providers\CartTemplatesServiceProvider;
use EscolaLms\TemplatesEmail\Providers\ConsultationTemplatesServiceProvider;
use EscolaLms\TemplatesEmail\Providers\CartTemplatesServiceProvider;
use EscolaLms\TemplatesEmail\Providers\CourseTemplatesServiceProvider;
use EscolaLms\TemplatesEmail\Providers\CsvUsersTemplatesServiceProvider;
use EscolaLms\TemplatesEmail\Providers\TemplateServiceProvider;
Expand Down

0 comments on commit e53009a

Please sign in to comment.