コード例 #1
0
ファイル: Mailer.php プロジェクト: alex-oleshkevich/zf-extras
 /**
  * 
  * @param array $options
  * @throws Exception
  */
 protected function setOptions(array $options)
 {
     if (!isset($options['transport']['name'])) {
         throw new Exception('No mail transport.');
     }
     $transportClass = $options['transport']['name'];
     if ($transportClass == Sendmail::class && isset($options['transport']['options'])) {
         $this->transport = new $transportClass($options['transport']['options']);
     } else {
         $this->transport = new $transportClass();
     }
     if (!$this->transport instanceof TransportInterface) {
         throw new Exception('Transport must implement Zend\\Mail\\Transport\\TransportInterface');
     }
     if (method_exists($this->transport, 'getOptions')) {
         $transportOptions = $this->transport->getOptions();
         $transportOptions->setFromArray($options['transport']['options']);
         $this->transport->setOptions($transportOptions);
     }
 }