From 49d07315f302a9ca691741cece0103fdeacb8b74 Mon Sep 17 00:00:00 2001 From: Boris Blondin Date: Tue, 11 Jan 2022 06:19:22 +0000 Subject: [PATCH] give a default value to redactor config --- CHANGELOG.md | 6 ++++++ src/behaviors/MessageBehavior.php | 2 +- src/helpers/RedactorHelper.php | 5 +++-- src/models/Email.php | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0275163..1c05c9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Web Puzzlers Emails Changelog +## 1.2.2 - 2022-01-11 + +### Fixed +- Error when redactor config is not populated +- Redactor config defaults to 'Default.json' + ## 1.2.1 - 2022-01-11 ### Fixed diff --git a/src/behaviors/MessageBehavior.php b/src/behaviors/MessageBehavior.php index 8e8a610..41b432d 100644 --- a/src/behaviors/MessageBehavior.php +++ b/src/behaviors/MessageBehavior.php @@ -36,7 +36,7 @@ public function getParsedBody() return \Craft::$app->elements->parseRefs($this->owner->body); } - public function redactorInput(string $redactorConfig) + public function redactorInput(?string $redactorConfig) { \Craft::$app->view->registerAssetBundle(FieldAsset::class); RedactorAsset::registerTranslations(\Craft::$app->view); diff --git a/src/helpers/RedactorHelper.php b/src/helpers/RedactorHelper.php index 8926bea..78565a6 100644 --- a/src/helpers/RedactorHelper.php +++ b/src/helpers/RedactorHelper.php @@ -16,10 +16,11 @@ class RedactorHelper { /** * Get redactor settings - * + * + * @param ?string $redactorConfigFile * @return array */ - public static function getRedactorSettings(string $redactorConfigFile): array + public static function getRedactorSettings(?string $redactorConfigFile): array { $redactorConfig = []; if ($redactorConfigFile) { diff --git a/src/models/Email.php b/src/models/Email.php index 1b560cc..3dfa4b3 100644 --- a/src/models/Email.php +++ b/src/models/Email.php @@ -19,7 +19,7 @@ class Email extends Model public $dateCreated; public $dateUpdated; public $template = 'emails/template'; - public $redactorConfig; + public $redactorConfig = 'Default.json'; public $system = false; public $plain = false; public $bcc;