From a8f49ef1988f5939757d6cca49c34a1af45116a2 Mon Sep 17 00:00:00 2001 From: Hubert Krzysztofiak Date: Wed, 23 Feb 2022 08:48:12 +0100 Subject: [PATCH 1/2] Add template to consultations package --- composer.json | 4 +- src/Consultations/ApprovedTermVariables.php | 17 ++++++ .../CommonConsultationVariables.php | 55 +++++++++++++++++++ src/Consultations/RejectTermVariables.php | 17 ++++++ src/Consultations/ReportTermVariables.php | 17 ++++++ ...EscolaLmsTemplatesEmailServiceProvider.php | 5 ++ .../ConsultationTemplatesServiceProvider.php | 23 ++++++++ 7 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/Consultations/ApprovedTermVariables.php create mode 100644 src/Consultations/CommonConsultationVariables.php create mode 100644 src/Consultations/RejectTermVariables.php create mode 100644 src/Consultations/ReportTermVariables.php create mode 100644 src/Providers/ConsultationTemplatesServiceProvider.php diff --git a/composer.json b/composer.json index cf7be3c..ee96bda 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "escolalms/cart": "^0", "escolalms/permissions": "^0", "escolalms/settings": "^0.1.2", + "escolalms/consultations": "^0", "escolalms/csv-users": "^0.1.0", "escolalms/assign-without-account": "^0", "orchestra/testbench": "^5.0|^6.0", @@ -26,7 +27,8 @@ "suggest": { "escolalms/auth": "^0.1.54", "escolalms/courses": "^0.3.8", - "escolalms/settings": "^0.1.2" + "escolalms/settings": "^0.1.2", + "escolalms/consultations": "^0" }, "license": "MIT", "authors": [ diff --git a/src/Consultations/ApprovedTermVariables.php b/src/Consultations/ApprovedTermVariables.php new file mode 100644 index 0000000..e2088bd --- /dev/null +++ b/src/Consultations/ApprovedTermVariables.php @@ -0,0 +1,17 @@ + '', + 'content' => '' + ]; + } +} diff --git a/src/Consultations/CommonConsultationVariables.php b/src/Consultations/CommonConsultationVariables.php new file mode 100644 index 0000000..fac274b --- /dev/null +++ b/src/Consultations/CommonConsultationVariables.php @@ -0,0 +1,55 @@ + $faker->name(), + self::VAR_COURSE_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, + ]); + } + + public static function requiredVariables(): array + { + return [ + self::VAR_USER_NAME, + self::VAR_COURSE_TITLE, + ]; + } + + public static function requiredVariablesInSection(string $sectionKey): array + { + if ($sectionKey === 'content') { + [ + self::VAR_USER_NAME, + self::VAR_COURSE_TITLE, + ]; + } + return []; + } + + public static function assignableClass(): ?string + { + return ConsultationTerm::class; + } +} diff --git a/src/Consultations/RejectTermVariables.php b/src/Consultations/RejectTermVariables.php new file mode 100644 index 0000000..9048d16 --- /dev/null +++ b/src/Consultations/RejectTermVariables.php @@ -0,0 +1,17 @@ + '', + 'content' => '' + ]; + } +} diff --git a/src/Consultations/ReportTermVariables.php b/src/Consultations/ReportTermVariables.php new file mode 100644 index 0000000..f064e61 --- /dev/null +++ b/src/Consultations/ReportTermVariables.php @@ -0,0 +1,17 @@ + '', + 'content' => '' + ]; + } +} diff --git a/src/EscolaLmsTemplatesEmailServiceProvider.php b/src/EscolaLmsTemplatesEmailServiceProvider.php index 07399ff..7de8ed1 100644 --- a/src/EscolaLmsTemplatesEmailServiceProvider.php +++ b/src/EscolaLmsTemplatesEmailServiceProvider.php @@ -7,6 +7,7 @@ use EscolaLms\Auth\Events\ForgotPassword; use EscolaLms\Auth\Listeners\CreatePasswordResetToken; use EscolaLms\Auth\Listeners\SendEmailVerificationNotification; +use EscolaLms\Consultations\EscolaLmsConsultationsServiceProvider; use EscolaLms\Settings\Facades\AdministrableConfig; use EscolaLms\Templates\EscolaLmsTemplatesServiceProvider; use EscolaLms\Templates\Repository\Contracts\TemplateRepositoryContract; @@ -14,6 +15,7 @@ use EscolaLms\TemplatesEmail\Providers\AssignWithoutAccountTemplatesEventServiceProvider; use EscolaLms\TemplatesEmail\Providers\AuthTemplatesEventServiceProvider; use EscolaLms\TemplatesEmail\Providers\AuthTemplatesServiceProvider; +use EscolaLms\TemplatesEmail\Providers\ConsultationTemplatesServiceProvider; use EscolaLms\TemplatesEmail\Providers\CourseTemplatesServiceProvider; use EscolaLms\TemplatesEmail\Providers\CsvUsersTemplatesServiceProvider; use EscolaLms\TemplatesEmail\Rules\MjmlRule; @@ -59,6 +61,9 @@ class_exists(EscolaLmsTemplatesServiceProvider::class) && if (class_exists(\EscolaLms\AssignWithoutAccount\EscolaLmsAssignWithoutAccountServiceProvider::class)) { $this->app->register(AssignWithoutAccountTemplatesEventServiceProvider::class); } + if (class_exists(EscolaLmsConsultationsServiceProvider::class)) { + $this->app->register(ConsultationTemplatesServiceProvider::class); + } } public function boot() diff --git a/src/Providers/ConsultationTemplatesServiceProvider.php b/src/Providers/ConsultationTemplatesServiceProvider.php new file mode 100644 index 0000000..61adfe9 --- /dev/null +++ b/src/Providers/ConsultationTemplatesServiceProvider.php @@ -0,0 +1,23 @@ + Date: Wed, 23 Feb 2022 09:00:19 +0100 Subject: [PATCH 2/2] Change import user --- src/Consultations/CommonConsultationVariables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Consultations/CommonConsultationVariables.php b/src/Consultations/CommonConsultationVariables.php index fac274b..8193031 100644 --- a/src/Consultations/CommonConsultationVariables.php +++ b/src/Consultations/CommonConsultationVariables.php @@ -2,8 +2,8 @@ namespace EscolaLms\TemplatesEmail\Consultations; -use EscolaLms\Auth\Models\User; use EscolaLms\Consultations\Models\ConsultationTerm; +use EscolaLms\Core\Models\User; use EscolaLms\Templates\Events\EventWrapper; use EscolaLms\TemplatesEmail\Core\EmailVariables;