Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eugene Terentev
committed
Jan 26, 2016
1 parent
084992b
commit 07c5af2
Showing
15 changed files
with
135 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 18 additions & 5 deletions
23
...commands/handler/AddToTimelineHandler.php → common/commands/AddToTimelineCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace common\commands; | ||
|
||
use yii\base\Object; | ||
use yii\swiftmailer\Message; | ||
use trntv\bus\interfaces\SelfHandlingCommand; | ||
|
||
/** | ||
* @author Eugene Terentev <eugene@terentev.net> | ||
*/ | ||
class SendEmailCommand extends Object implements SelfHandlingCommand | ||
{ | ||
/** | ||
* @var mixed | ||
*/ | ||
public $from; | ||
/** | ||
* @var mixed | ||
*/ | ||
public $to; | ||
/** | ||
* @var string | ||
*/ | ||
public $subject; | ||
/** | ||
* @var string | ||
*/ | ||
public $view; | ||
/** | ||
* @var array | ||
*/ | ||
public $params; | ||
/** | ||
* @var string | ||
*/ | ||
public $body; | ||
/** | ||
* @var bool | ||
*/ | ||
public $html = true; | ||
|
||
/** | ||
* Command init | ||
*/ | ||
public function init() | ||
{ | ||
$this->from = $this->from ?: \Yii::$app->params['robotEmail']; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isHtml() | ||
{ | ||
return (bool) $this->html; | ||
} | ||
|
||
/** | ||
* @param \common\commands\SendEmailCommand $command | ||
* @return bool | ||
*/ | ||
public function handle($command) | ||
{ | ||
if (!$command->body) { | ||
$message = \Yii::$app->mailer->compose($command->view, $command->params); | ||
} else { | ||
$message = new Message(); | ||
if ($command->isHtml()) { | ||
$message->setHtmlBody($command->body); | ||
} else { | ||
$message->setTextBody($command->body); | ||
} | ||
} | ||
$message->setFrom($command->from); | ||
$message->setTo($command->to ?: \Yii::$app->params['robotEmail']); | ||
$message->setSubject($command->subject); | ||
return $message->send(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.