for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the WPSymfonyForm plugin.
*
* Copyright (c) 2015-2016 LIN3S <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace LIN3S\WPSymfonyForm\Action;
use Symfony\Component\Form\FormInterface;
/**
* Class MailerAction.
* @author Gorka Laucirica <[email protected]>
class MailerAction implements Action
{
* The email subject.
* @var string
private $subject;
* The email HTML template.
private $template;
* The receiver email.
private $to;
* Constructor.
* @param string $to The receiver email
* @param string $template The email HTML template
* @param string $subject The email subject
public function __construct($to, $template, $subject)
$this->to = $to;
$this->template = $template;
$this->subject = $subject;
}
* {@inheritdoc}
public function execute(FormInterface $form)
if (class_exists('\Timber\Timber')) {
$message = \Timber\Timber::compile($this->template, ['request' => $form->getData()]);
} elseif (class_exists('\Timber')) {
$message = \Timber::compile($this->template, ['request' => $form->getData()]);
} else {
throw new \InvalidArgumentException('Timber is required to use MailerAction');
wp_mail($this->to, $this->subject, $message, [
'Content-Type: text/html; charset=UTF-8',
]);