Skip to content

Commit

Permalink
Merge branch 'release/3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Mar 28, 2022
2 parents fc563d3 + 1f151ec commit 1bbc8bd
Show file tree
Hide file tree
Showing 95 changed files with 189 additions and 23,933 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# v3.2.0
## 03/28/2022

1. [](#new)
* Require **Grav 1.7.32** and **Form 6.0.0**
1. [](#improved)
* Added access email message object inside the twig template file
2. [](#bugfix)
* Fixed twig not being initialized when building an email message

# v3.1.5
## 01/03/22
## 01/03/2022

1. [](#improved)
* Updated to Swiftmailer `v6.3.0` with PHP 8.1 compatibility [#157](https://github.com/getgrav/grav-plugin-email/issues/157)
Expand Down
6 changes: 3 additions & 3 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Email
slug: email
type: plugin
version: 3.1.5
version: 3.2.0
testing: false
description: Enables the emailing system for Grav
icon: envelope
Expand All @@ -15,8 +15,8 @@ bugs: https://github.com/getgrav/grav-plugin-email/issues
license: MIT

dependencies:
- { name: grav, version: '>=1.6.0' }
- { name: form, version: '>=3.0.3' }
- { name: grav, version: '>=1.7.32' }
- { name: form, version: '>=6.0.0' }

form:
validation: loose
Expand Down
14 changes: 9 additions & 5 deletions classes/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,17 @@ public function buildMessage(array $params, array $vars = [])
{
/** @var Twig $twig */
$twig = Grav::instance()['twig'];
$twig->init();

/** @var Config $config */
$config = Grav::instance()['config'];

/** @var Language $language */
$language = Grav::instance()['language'];

// Create message object.
$message = $this->message();

// Extend parameters with defaults.
$params += [
'bcc' => $config->get('plugins.email.bcc', []),
Expand All @@ -159,12 +163,10 @@ public function buildMessage(array $params, array $vars = [])
'to' => $config->get('plugins.email.to'),
'to_name' => $config->get('plugins.email.to_name'),
'process_markdown' => false,
'template' => false
'template' => false,
'message' => $message
];

// Create message object.
$message = $this->message();

if (!$params['to']) {
throw new \RuntimeException($language->translate('PLUGIN_EMAIL.PLEASE_CONFIGURE_A_TO_ADDRESS'));
}
Expand Down Expand Up @@ -233,7 +235,9 @@ public function buildMessage(array $params, array $vars = [])
break;

case 'subject':
$message->setSubject($twig->processString($language->translate($value), $vars));
if ($value) {
$message->setSubject($twig->processString($language->translate($value), $vars));
}
break;

case 'to':
Expand Down
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,24 @@
"docs": "https://github.com/getgrav/grav-plugin-email/blob/master/README.md"
},
"require": {
"php": ">=7.1.3",
"php": ">=7.3.6",
"swiftmailer/swiftmailer": "~6.0"
},
"replace": {
"symfony/polyfill-iconv": "*",
"symfony/polyfill-mbstring": "*",
"symfony/polyfill-php72": "*"
},
"autoload": {
"psr-4": {
"Grav\\Plugin\\Email\\": "classes/",
"Grav\\Plugin\\Console\\": "cli/"
},
"classmap": ["email.php"]
},
"config": {
"platform": {
"php": "7.3.6"
}
}
}
Loading

0 comments on commit 1bbc8bd

Please sign in to comment.