Invoked immediately before the Message is sent.

@param \Swift_Events_SendEvent $evt

@throws \Throwable
198560
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
    {
        if (\Swift_Events_SendEvent::RESULT_PENDING === $evt->getResult() && (null === $this->msg)) {
            $this->msg = $evt->getMessage();
            $locale = $this->request->getCurrentRequest()->getLocale() ?? 'en';

            // Find & Remove Template ID
            $templateID = null;
            if (null !== ($tID = $this->msg->getHeaders()->get('TemplateID'))) {
                $templateID = $tID->getFieldBody();
                $this->msg->getHeaders()->remove('TemplateID');
            }

            // Create Log
            if ($this->bag->get('pd_mailer.logger_active')) {
                $this->logCreate($evt->getMessage(), $evt->getResult(), $templateID, $locale);
            }

            // Set Message From
            if (\count($this->msg->getFrom()) < 1) {
                $evt->getMessage()->setFrom(
                    $this->bag->get('pd_mailer.sender_address'),
                    $this->bag->get('pd_mailer.sender_name')
                );
            }

            // Render Template
            if (null !== $templateID) {
                if ($this->bag->get('pd_mailer.logger_active')) {
                    $this->engine->render($templateID, $locale, $this->msg);
                }
            }
        }
    }
453667
public function beforeApiRequestSend($event)
    {
        $request = $event->request;
        $data = $request->getData();
        $data['openid'] = $this->getOpenid();
        $request->setData($data);

        parent::beforeApiRequestSend($event);
    }
77300
public function sendPerformed(Swift_Events_SendEvent $evt)
    {
        $message = $evt->getMessage();
        $failures = array_flip($evt->getFailedRecipients());
        foreach ((array) $message->getTo() as $address => $null) {
            $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS));
        }
        foreach ((array) $message->getCc() as $address => $null) {
            $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS));
        }
        foreach ((array) $message->getBcc() as $address => $null) {
            $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS));
        }
    }
922430
public function beforeRender(Event $event)
    {
        parent::beforeRender($event);

        $this->set('detect', $this->detect);
    }
104217
public function sendPerformed(\Swift_Events_SendEvent $evt)
    {
        if ($this->bag->get('pd_mailer.logger_active')) {
            if (!\in_array($evt->getResult(), [\Swift_Events_SendEvent::RESULT_PENDING, \Swift_Events_SendEvent::RESULT_SPOOLED], true)) {
                $this->logUpdate($evt->getMessage(), $evt->getResult());
            }
        }
    }
558155
private void enqueueSessionEvent(final IoSessionEvent evt) {
        synchronized (sessionEventsQueue) {
            logger.debug("Enqueuing event: {}", evt);
            sessionEventsQueue.offer(evt);
        }    
    }
537983
public function onPreSetData(FormEvent $event)
    {
        $contentLanguages = [];
        $form = $event->getForm();

        /** @var TranslationAddData $data */
        $data = $event->getData();
        $contentType = $data->getContentType();

        if (null !== $contentType) {
            $contentLanguages = array_keys($contentType->getNames());
        }

        $this->addLanguageFields($form, $contentLanguages);
    }
158046
public function beforeActionResponse($actionEvent)
    {
        Yii::$app->response->action = $actionEvent->action;
        Yii::$app->response->controller = $this;
    }
1223965
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
    {
        $time = $this->getTimestamp();
        if (!isset($this->start)) {
            $this->start = $time;
        }
        $duration = $time - $this->start;

        switch ($this->mode) {
            case self::BYTES_PER_MINUTE:
                $sleep = $this->throttleBytesPerMinute($duration);
                break;
            case self::MESSAGES_PER_SECOND:
                $sleep = $this->throttleMessagesPerSecond($duration);
                break;
            case self::MESSAGES_PER_MINUTE:
                $sleep = $this->throttleMessagesPerMinute($duration);
                break;
            default:
                $sleep = 0;
                break;
        }

        if ($sleep > 0) {
            $this->sleep($sleep);
        }
    }
431213
public synchronized void fireEvent(Event evt) {
		if (evt == null) {
			return;
		}

		// Process global listeners
		for (Enumeration<EventListener> keys = globalListeners.elements(); keys
				.hasMoreElements();) {
			EventListener mListener = keys.nextElement();
			try {
				mListener.processEvent(evt);
			} catch (Throwable t) {
			}
		}

		String sourceThread = Thread.currentThread().getName();

		for (Enumeration<String> keys = keyedListeners.keys(); keys
				.hasMoreElements();) {
			String key = (String) keys.nextElement();
			// We don't want badly behaved listeners to throw uncaught
			// exceptions and upset other listeners
			try {
				String prefix = "";
				if (sourceThread.indexOf('-') > -1) {
					prefix = sourceThread.substring(0,
							sourceThread.indexOf('-'));

					if (key.startsWith(prefix)) {
						EventListener mListener = keyedListeners.get(key);
						mListener.processEvent(evt);
					}
				}

			} catch (Throwable thr) {
				// log.error("Event failed.", thr);
			}
		}
	}
577494
function(evt) {
            var e = {
              target: this,
              type: evt.type,
              evt: evt
            };
            this.fire(evt.type, e);
        }
1240721
public function onMessageSendingToUsers(SendMessageEvent $event)
    {
        $message = $this->messageManager->create(
            $event->getContent(),
            $event->getObject(),
            $event->getUsers(),
            $event->getSender()
        );

        $this->messageManager->send($message);
    }
428567
public function onMessageSending(SendMessageEvent $event)
    {
        $receiver = $event->getReceiver();
        $sender = $event->getSender();
        $content = $event->getContent();
        $object = $event->getObject();
        $withMail = $event->getWithMail();
        $this->messageManager->sendMessageToAbstractRoleSubject(
            $receiver,
            $content,
            $object,
            $sender,
            $withMail
        );
    }
476348
public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt)
    {
        if ($this->bag->get('pd_mailer.logger_active')) {
            // Update Data
            $this->log->setStatus(\Swift_Events_SendEvent::RESULT_FAILED);
            $this->log->addException($evt->getException()->getMessage() . PHP_EOL);

            // Update
            $this->entityManager->persist($this->log);
            $this->entityManager->flush();
        }
    }
813288
public function sendPerformed(Swift_Events_SendEvent $evt)
    {
        ++$this->counter;
        if ($this->counter >= $this->threshold) {
            $transport = $evt->getTransport();
            $transport->stop();
            if ($this->sleep) {
                $this->sleep($this->sleep);
            }
            $transport->start();
            $this->counter = 0;
        }
    }
472019
public function beforeRender(Event $event)
    {
        if (!array_key_exists('_serialize', $this->viewVars) &&
            in_array($this->response->type(), ['application/json', 'application/xml'])
        ) {
            $this->set('_serialize', true);
        }
    }
1330355
function (evt, callback) {
    if (!evt || !_.isObject(evt)) {
      var err = new Error('Please pass a valid event!');
      debug(err);
      throw err;
    }

    if (!callback || !_.isFunction(callback)) {
      var err = new Error('Please pass a valid callback!');
      debug(err);
      throw err;
    }

    var target = this.getTargetInformation(evt);

    var viewBuilders = this.tree.getViewBuilders(target);

    var errs = [];
    var notifications = [];

    var foundPrioSet = _.find(viewBuilders, function (vb) {
      return vb.priority < Infinity;
    });

    var eachMethod = 'each';
    if (foundPrioSet) {
      eachMethod = 'eachSeries';
    }

    async[eachMethod].call(async, viewBuilders, function (viewBuilder, callback) {
      viewBuilder.denormalize(evt, function (err, notis) {
        if (err) {
          debug(err);
          if (!errs.push) {
            var warn = new Error('ATTENTION! Already called back!');
            debug(warn);
            console.log(warn.stack);
            return;
          }
          errs.push(err);
        }

        if (notis && notis.length > 0) {
          notifications = notifications.concat(notis);
        }
        callback(null);
      });
    }, function () {
      if (errs.length === 0) {
        errs = null;
      }
      callback(errs, _.filter(notifications, function (n) { return !!n; }));
    });
  }