Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\base\Component
Exemple #1
0
 public function init()
 {
     parent::init();
     Event::on(View::className(), View::EVENT_BEFORE_RENDER, function (ViewEvent $event) {
         $this->_viewFiles[] = $event->sender->getViewFile();
     });
 }
Exemple #2
0
 public function init()
 {
     parent::init();
     Event::on(BaseStorage::className(), BaseStorage::EVENT_READFILE, function ($e) {
         $this->addItem($e);
     });
 }
Exemple #3
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!isset($this->module->panels['profiling'])) {
         throw new InvalidConfigException('Unable to determine the profiling panel');
     }
     parent::init();
 }
 public function init()
 {
     parent::init();
     //Try get instance from cache
     $cache = Yii::$app->get($this->componentName, false);
     if ($cache !== null && $cache instanceof MemCache) {
         $this->instance = $cache->getMemcache();
     }
 }
Exemple #5
0
 public function init()
 {
     parent::init();
     Event::on(BaseMailer::className(), BaseMailer::EVENT_AFTER_SEND, function ($event) {
         $message = $event->message->getSwiftMessage();
         $textBody = $message->getBody();
         $fileName = $event->sender->generateMessageFileName();
         FileHelper::createDirectory(Yii::getAlias($this->mailPath));
         file_put_contents(Yii::getAlias($this->mailPath) . '/' . $fileName, $message->toString());
         $this->_messages[] = ['isSuccessful' => $event->isSuccessful, 'time' => $message->getDate(), 'headers' => $message->getHeaders(), 'from' => $this->convertParams($message->getFrom()), 'to' => $this->convertParams($message->getTo()), 'reply' => $this->convertParams($message->getReplyTo()), 'cc' => $this->convertParams($message->getCc()), 'bcc' => $this->convertParams($message->getBcc()), 'subject' => $message->getSubject(), 'body' => $textBody, 'charset' => $message->getCharset(), 'file' => $fileName];
     });
 }
Exemple #6
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     Event::on(BaseMailer::className(), BaseMailer::EVENT_AFTER_SEND, function ($event) {
         /* @var $message MessageInterface */
         $message = $event->message;
         $messageData = ['isSuccessful' => $event->isSuccessful, 'from' => $this->convertParams($message->getFrom()), 'to' => $this->convertParams($message->getTo()), 'reply' => $this->convertParams($message->getReplyTo()), 'cc' => $this->convertParams($message->getCc()), 'bcc' => $this->convertParams($message->getBcc()), 'subject' => $message->getSubject(), 'charset' => $message->getCharset()];
         // add more information when message is a SwiftMailer message
         if ($message instanceof \yii\swiftmailer\Message) {
             /* @var $swiftMessage \Swift_Message */
             $swiftMessage = $message->getSwiftMessage();
             $messageData['body'] = $swiftMessage->getBody();
             $messageData['time'] = $swiftMessage->getDate();
             $messageData['headers'] = $swiftMessage->getHeaders();
         }
         // store message as file
         $fileName = $event->sender->generateMessageFileName();
         FileHelper::createDirectory(Yii::getAlias($this->mailPath));
         file_put_contents(Yii::getAlias($this->mailPath) . '/' . $fileName, $message->toString());
         $messageData['file'] = $fileName;
         $this->_messages[] = $messageData;
     });
 }