add events + more wip classes

This commit is contained in:
Antonio Ramirez
2016-12-04 15:53:09 +01:00
parent 3e16d24048
commit bd06010018
21 changed files with 496 additions and 18 deletions

View File

@ -2,11 +2,51 @@
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
use yii\swiftmailer\Mailer;
use Yii;
class MailService implements ServiceInterface
{
protected $viewPath = '@Da/User/resources/views/mail';
protected $from;
protected $to;
protected $subject;
protected $view;
protected $params = [];
protected $mailer;
/**
* MailService constructor.
*
* @param string $from
* @param string $to
* @param string $subject
* @param string $view
* @param array $params
* @param Mailer $mailer
*/
public function __construct($from, $to, $subject, $view, array $params, Mailer $mailer)
{
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->view = $view;
$this->params = $params;
$this->mailer = $mailer;
$this->mailer->setViewPath($this->viewPath);
$this->mailer->getView()->theme = Yii::$app->view->theme;
}
/**
* @return bool
*/
public function run()
{
// TODO: Implement run() method.
return $this->mailer->compose(['html' => $this->view, 'text' => "text/{$this->view}"], $this->params)
->setFrom($this->from)
->setTo($this->to)
->setSubject($this->subject)
->send();
}
}