| Current Path : /var/www/html/eform/frontend/queue/ |
| Current File : /var/www/html/eform/frontend/queue/NotificationEmailJob.php |
<?php
namespace frontend\queue;
use Yii;
use yii\base\BaseObject;
use frontend\models\Notification;
class NotificationEmailJob extends BaseObject implements \yii\queue\JobInterface
{
public $ref_id;
public $ref_code;
public $body;
public $recipient;
public $recipient_cc;
public $view;
public $data;
public function execute($queue)
{
try {
$noti = Notification::email(
$this->ref_id,
$this->ref_code,
$this->body,
$this->recipient,
$this->recipient_cc,
$this->view,
$this->data
);
if(!$noti) {
throw new \Exception("Error Sending Email.. :- please check body->content, body->subject is set.");
}
} catch (\Throwable $t) {
$this->body['error'] = $t->getMessage();
$noti = new Notification();
$noti->reference_id = $this->ref_id;
$noti->reference_code = $this->ref_code;
$noti->subject = $this->body['subject'];
$noti->body = json_encode($this->body);
$noti->recipient = json_encode($this->recipient);
$noti->type = 'EMAIL';
$noti->status = 'FAILED';
$noti->save();
}
}
}
?>