Sends the event through all senders

@param Event $event

@return $this
162212
protected function sendEventThroughSenders(Event $event)
    {
        foreach ($this->eventSenders as $sender) {
            try {
                $sender->send($event);
            } catch (\Exception $exception) {
                $this->logException($exception);
            }
        }

        return $this;
    }
947632
public function handle(Event $event)
    {
        $name = $event->getName();
        list(, $method) = explode('.', $name);
        if (empty($this->_config['for']) && empty($this->_config['when'])) {
            return $this->{$method}($event);
        }
        if ($this->matches($event)) {
            return $this->{$method}($event);
        }
    }
1072221
public function dispatch($event)
    {
        if ($event instanceof AbstractEvent) {
            $this->dispatcher->dispatch($event->getEventName(), $event);
        } else {
            $this->dispatcher->dispatch($event);
        }
        return $this;
    }
1214871
public function onEvent(Event $event = null)
    {
        while (!empty($this->messages)) {
            $message = array_shift($this->messages);

            $this->handle($message, $this->dispatcher);
        }
    }
474163
protected function sortListeners(string $event) : interfaces\Emitter
    {
        if (!isset($this->listeners[$event])) {
            return $this;
        }

        // Sort the listeners by priority in a descending order.
        krsort($this->listeners[$event]);

        $this->chain[$event] = array_merge(...$this->listeners[$event]);

        return $this;
    }
154732
public function clearListeners($event = null)
	{
		if ($event)
		{
			$event = $this->resolveEventName($event);

			if (isset($this->listeners[$event]))
			{
				unset($this->listeners[$event]);
			}
		}
		else
		{
			$this->listeners = array();
		}

		return $this;
	}
1085050
public function setTaskAsDone(Event $event)
    {
        $this->checkPermission($event);
        if ($event->isTaskDone()) {
            throw new \Exception('This task is already mark as done.');
        }

        $event->setIsTaskDone(true);
        $om = $this->getDoctrine()->getManager();
        $om->flush();

        return new Response();
    }
256713
public function addEvent(Event $event)
    {
        $this->clear();
        $this->events[$event->getName()] = $event;

        return $this;
    }
1100231
public function send(Event $event)
    {
        $level = $this->getEventLevel($event);
        $message = $this->getEventMessage($event);
        $tags = $this->getEventTags($event);

        $this->logger->log($level, $message, $tags);
    }
785891
public function onRequestBeforeSend(Event $event)
    {
        $request = $event['request'];

        $request->setHeader('Accept',(string) $this->config['accept-header']);

        return $this->config['accept-header'];
    }
866846
public function setFlash(Event $event)
    {
        unset($event->getSubject()->params['class']);
        $event->getSubject()->element = ltrim($event->getSubject()->type);
    }
439795
public function dispatch(Event $event) {
    
    foreach ($this->getSubscribers($event) as $subscriber) {
      $subscriber->trigger($event);
    }
    
    return $this;
  }
707112
public function addEvent($event, array $params = []): self
    {
        $event = $this->wrapperEvent($event, null, $params);

        /** @var $event Event */
        if (($event instanceof EventInterface) && !isset($this->events[$event->getName()])) {
            $this->events[$event->getName()] = $event;
        }

        return $this;
    }
1139123
public function triggerEvent($event)
	{
		if (!($event instanceof EventInterface))
		{
			if (isset($this->events[$event]))
			{
				$event = $this->events[$event];
			}

			else
			{
				$event = new Event($event);
			}
		}

		if (isset($this->listeners[$event->getName()]))
		{
			foreach ($this->listeners[$event->getName()] as $listener)
			{
				if ($event->isStopped())
				{
					return $event;
				}

				if ($listener instanceof Closure)
				{
					call_user_func($listener, $event);
				}

				else
				{
					call_user_func(array($listener, $event->getName()), $event);
				}
			}
		}

		return $event;
	}
483714
public function emit($event, array $args)
    {
        $this->logger->debug('Sending a new message', ['event' => $event, 'args' => $args]);
        $this->engine->emit($event, $args);

        return $this;
    }
1050926
public function send($event)
    {
        $order = $event->model;
        $mail = $order->orderStatus->mail;
        $smsTemplate = $order->orderStatus->smsTemplate;

        if (!empty($mail)) {
            try {

                /**
                 * @var $mailTemplate Template
                 */
                $mailTemplate = Yii::$app->get('emailTemplates')->getTemplate($mail->key, Language::getCurrent()->id);
                $vars = [
                    '{order_id}' => $order->uid,
                    '{order_sum}' => $order->total_cost,
                    '{created_at}' => $order->creation_time,
                    '{status}' => $order->orderStatus->translation->title,
                    '{order_invoice}' => $order->invoice,
                    '{order_pay_btn}' => $order->invoice
                        ? Html::tag('p', Html::a(Yii::t('order.mail', 'Pay'), $order->invoice, [
                            'target' => '_blank',
                            'style' => [
                                'background-color' => '#f09020',
                                'color' => '#ffffff',
                                'font-size' => '20px',
                                'padding' => '7px 13px',
                                'text-decoration' => 'none',
                                'border-radius' => '4px'
                            ]
                        ]), [
                            'style' => [
                                'text-align' => 'center'
                            ]
                        ])
                        : ''
                ];
                $mailTemplate->parseSubject($vars);
                $mailTemplate->parseBody($vars);

                Yii::$app->shopMailer->compose('mail-body',
                    ['bodyContent' => $mailTemplate->getBody()])
                    ->setFrom([\Yii::$app->cart->sender ?? \Yii::$app->shopMailer->transport->getUsername() => \Yii::$app->name ?? Url::to(['/'], true)])
                    ->setTo($order->user->email)
                    ->setSubject($mailTemplate->getSubject())
                    ->send();

            } catch (Exception $ex) {
                throw new Exception($ex);
            }
        }

        if(!empty($smsTemplate)) {
            $vars = [
                '{order_id}' => $order->uid,
                '{order_sum}' => $order->total_cost,
                '{order_invoice}' => Yii::$app->urlShortener->shorten($order->invoice)
            ];

            /** @var SmsMobizoneComponent $smsComponent */
            $smsComponent = Yii::$app->sms;
            $smsComponent->setSmsText(strtr($smsTemplate->translation->subject, $vars));
            $smsComponent->setRecipientPhoneNumber($order->user->profile->phone);
            $smsComponent->send();
        }
    }
92916
public function setEvent($event = [])
    {
        if (!empty($event['id'])) {
            $this->setLogs($event['id'], 'campaignEventId');
        }
        $overrides = [];
        if (!empty($event['config']['contactclient_overrides'])) {
            // Flatten overrides to key-value pairs.
            $jsonHelper = new JSONHelper();
            $array      = $jsonHelper->decodeArray($event['config']['contactclient_overrides'], 'Overrides');
            if ($array) {
                foreach ($array as $field) {
                    if (!empty($field->key) && !empty($field->value) && (empty($field->enabled) || true === $field->enabled)) {
                        $overrides[$field->key] = $field->value;
                    }
                }
            }
            if ($overrides) {
                $this->setOverrides($overrides);
            }
        }
        $this->event = $event;

        return $this;
    }