Skip to content

Commit

Permalink
Merge pull request #61 from bwaidelich/feature-emailfinisher-template…
Browse files Browse the repository at this point in the history
…source

FEATURE: Allow the EmailFinisher template source to be set
  • Loading branch information
Bastian Waidelich committed Aug 29, 2017
2 parents 5bd9730 + d8aa3e5 commit 489d4ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Classes/Finishers/EmailFinisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*
* Options:
*
* - templatePathAndFilename (mandatory): Template path and filename for the mail body
* - templatePathAndFilename (mandatory if "templateSource" option is not set): Template path and filename for the mail body
* - templateSource (mandatory if "templatePathAndFilename" option is not set): The raw Fluid template
* - layoutRootPath: root path for the layouts
* - partialRootPath: root path for the partials
* - variables: associative array of variables which are available inside the Fluid template
Expand Down Expand Up @@ -163,10 +164,14 @@ protected function executeInternal()
protected function initializeStandaloneView()
{
$standaloneView = new StandaloneView();
if (!isset($this->options['templatePathAndFilename'])) {
throw new FinisherException('The option "templatePathAndFilename" must be set for the EmailFinisher.', 1327058829);
if (isset($this->options['templatePathAndFilename'])) {
$standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']);
} elseif (isset($this->options['templateSource'])) {
$standaloneView->setTemplateSource($this->options['templateSource']);
} else {
throw new FinisherException('The option "templatePathAndFilename" or "templateSource" must be set for the EmailFinisher.', 1327058829);
}
$standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']);


if (isset($this->options['partialRootPath'])) {
$standaloneView->setPartialRootPath($this->options['partialRootPath']);
Expand All @@ -176,6 +181,8 @@ protected function initializeStandaloneView()
$standaloneView->setLayoutRootPath($this->options['layoutRootPath']);
}

$standaloneView->assign('formValues', $this->finisherContext->getFormValues());

if (isset($this->options['variables'])) {
$standaloneView->assignMultiple($this->options['variables']);
}
Expand Down
3 changes: 3 additions & 0 deletions Documentation/configuring-form-yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ The following YAML is stored as ``contact.yaml``:
senderName: '{name}'
format: plaintext
.. note:: Instead of setting the ``templatePathAndFilename`` option to specify the Fluid template file for the EmailFinisher,
the template source can also be set directly via the ``templateSource`` option.


File Uploads
------------
Expand Down

0 comments on commit 489d4ff

Please sign in to comment.