| Total Complexity | 7 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | class QueueSpool extends BaseSpool implements Swift_Spool |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var Queue|array|string the queue object or the application component ID of the queue object. |
||
| 24 | */ |
||
| 25 | public $queue = 'queue'; |
||
| 26 | /** |
||
| 27 | * @var array the default configuration of jobs. |
||
| 28 | */ |
||
| 29 | public $jobConfig = ['class' => 'izumi\spoolmailer\spools\QueueSpoolJob']; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @inheritdoc |
||
| 33 | */ |
||
| 34 | public function init() |
||
| 35 | { |
||
| 36 | $this->queue = Instance::ensure($this->queue, Queue::className()); |
||
| 37 | parent::init(); |
||
| 38 | $this->setTransport([ |
||
| 39 | 'class' => 'Swift_SpoolTransport', |
||
| 40 | 'constructArgs' => [$this], |
||
| 41 | ]); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @inheritdoc |
||
| 46 | */ |
||
| 47 | public function flush(BaseMailer $mailer, &$failedRecipients = null) |
||
| 48 | { |
||
| 49 | throw new NotSupportedException(); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @inheritdoc |
||
| 54 | */ |
||
| 55 | public function start() |
||
| 56 | { |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @inheritdoc |
||
| 61 | */ |
||
| 62 | public function stop() |
||
| 63 | { |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @inheritdoc |
||
| 68 | */ |
||
| 69 | public function isStarted() |
||
| 70 | { |
||
| 71 | return true; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @inheritdoc |
||
| 76 | */ |
||
| 77 | public function queueMessage(Swift_Mime_SimpleMessage $message) |
||
| 78 | { |
||
| 79 | $config = ArrayHelper::merge($this->jobConfig, ['message' => $message]); |
||
| 80 | $job = Yii::createObject($config); |
||
| 81 | |||
| 82 | return $this->queue->push($job) !== null; |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @inheritdoc |
||
| 87 | */ |
||
| 88 | public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) |
||
| 91 | } |
||
| 92 | } |
||
| 93 |