Calls event listener

@param string $eventName
@param mixed  $subject
@param mixed  $message

@return mixed
549427
protected function call($eventName, $subject = null, $message = null)
    {
        if (!isset($this->events[$eventName])) {
            return $subject;
        }

        foreach ($this->events[$eventName] as $listener) {
            if ($this->stop) {
                break;
            }

            $subject = $listener($this->container, $subject, $message, $eventName);
        }

        return $subject;
    }
962669
public function event($event, $level, $message, $context = []) {
        $context['event'] = $event;
        $this->log($level, $message, $context);
    }
519083
public function createMessage($subject = null, $body = null, $contentType = null, $charset = null)
    {
        $message = Swift_Message::newInstance($subject, $body, $contentType, $charset);

        if(null !== $this->fromEmail) {
            
            if(null === $this->fromName) {
                $message->setFrom($this->fromEmail);
            } else {
                $message->setFrom($this->fromEmail, $this->fromName);
            }
            
        }

        return $message;
    }
694486
public function recordEvent($eventName, $payload)
    {
        if (! Telescope::isRecording() || $this->shouldIgnore($eventName)) {
            return;
        }

        $formattedPayload = $this->extractPayload($eventName, $payload);

        Telescope::recordEvent(IncomingEntry::make([
            'name' => $eventName,
            'payload' => empty($formattedPayload) ? null : $formattedPayload,
            'listeners' => $this->formatListeners($eventName),
            'broadcast' => class_exists($eventName)
                        ? in_array(ShouldBroadcast::class, (array) class_implements($eventName))
                        : false,
        ])->tags(class_exists($eventName) && isset($payload[0]) ? ExtractTags::from($payload[0]) : []));
    }
1277617
public function notify()
    {
        \BFW\Application::getInstance()
            ->getMonolog()
            ->getLogger()
            ->debug(
                'Subject notify event',
                ['action' => $this->action]
            );
        
        foreach ($this->observers as $observer) {
            $observer->update($this);
        }
    }
805705
protected function _prepareEvent($eventName, array $data = [])
    {
        if (is_array($eventName)) {
            list($eventName, $subject) = $eventName;
        } else {
            $subject = new EventDispatcher();
        }

        return new Event($eventName, $subject, $data);
    }
1370552
public function messagesAction(Subject $subject, $page, $max)
    {
        $forum = $subject->getCategory()->getForum();
        $this->checkAccess($forum);
        $isAnon = $this->isAnon();
        $isModerator = $this->authorization->isGranted(
            'moderate',
            new ResourceCollection(array($forum->getResourceNode()))
        ) && !$isAnon;
        $pager = $this->manager->getMessagesPager($subject, $page, $max);
        $collection = new ResourceCollection(array($forum->getResourceNode()));
        $canPost = $this->authorization->isGranted('post', $collection);
        $form = $this->get('form.factory')->create(new MessageType());

        if (!$isAnon) {
            $securityToken = $this->tokenStorage->getToken();

            if (!is_null($securityToken)) {
                $user = $securityToken->getUser();
                $event = new ReadSubjectEvent($subject);
                $event->setDoer($user);
                $this->dispatch($event);
            }
        }

        return array(
            'subject' => $subject,
            'pager' => $pager,
            '_resource' => $forum,
            'isModerator' => $isModerator,
            'form' => $form->createView(),
            'category' => $subject->getCategory(),
            'max' => $max,
            'canPost' => $canPost,
            'workspace' => $forum->getResourceNode()->getWorkspace()
        );
    }
1344110
public static function send(string $to, string $subject, string $view, array $viewVars = [], $builder = null, $from = 'default')
    {
        $message = static::createMessage($to, $subject, $from);
        if (is_callable($builder)) {
            $builder($message);
        }
        $message->setBody(static::view($view, $viewVars));

        self::getMailer()->send($message);
    }
476809
public function update(SplSubject $subject, $event = null)
    {
        switch ($event) {
            case 'log':
                /* @var Doozr_Logging $subject */
                $logs = $subject->getCollectionRaw();

                foreach ($logs as $log) {
                    $this->log(
                        $log['type'],
                        $log['message'],
                        unserialize($log['context']),
                        $log['time'],
                        $log['fingerprint'],
                        $log['separator']
                    );
                }
                break;
        }
    }
1319880
public function call(Message $message) : Message
    {
        $aggregate = $message->getHeaders()->containsKey(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_HEADER)
                            ? $message->getHeaders()->get(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_HEADER)
                            : null;
        $methodInvoker = MethodInvoker::createWith(
            $aggregate ? $aggregate : $message->getHeaders()->get(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_CLASS_NAME_HEADER),
            $message->getHeaders()->get(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_METHOD_HEADER),
            $this->messageToParameterConverters
        );

        $resultMessage = MessageBuilder::fromMessage($message);
        try {
            $result = $methodInvoker->processMessage($message);

            if (!$aggregate) {
                $resultMessage = $resultMessage
                    ->setHeader(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_HEADER, $result);
            }
        } catch (\Throwable $e) {
            throw MessageHandlingException::fromOtherException($e, $message);
        }

        if (!is_null($result)) {
            $resultMessage = $resultMessage
                ->setPayload($result);
        }

        return $resultMessage
                ->build();
    }
1275085
public function receiveAnEmailWithSubject($subject)
    {
        $message = $this->fetchLastMessage();
        $this->assertEquals($subject, $message->subject);
    }
1202569
public function waitForEmailWithSubject($subject, $timeout = 5)
    {
        $condition = function () use ($subject) {
            $emails = $this->fetchMessages();
            foreach ($emails as $email) {
                $constraint = Assert::equalTo($subject);
                if ($constraint->evaluate($email->subject, '', true)) {
                    return true;
                }
            }

            return false;
        };

        $message = sprintf('Waited for %d secs but no email with the subject of %s has arrived', $timeout, $subject);

        $this->wait($timeout)->until($condition, $message);
    }
225219
public function createMessageAction(Subject $subject)
    {
        $form = $this->container->get('form.factory')->create(new MessageType, new Message());
        $form->handleRequest($this->get('request'));


        if ($form->isValid()) {
            $message = $form->getData();
            $this->manager->createMessage($message, $subject);
        }

        return new RedirectResponse(
            $this->generateUrl('claro_forum_messages', array('subject' => $subject->getId()))
        );
    }
831577
public function update(\SplSubject $subject)
    {
        if (!$subject instanceof EventInterface) {
            throw new \InvalidArgumentException('Command can only be attached to an event!');
        }
        if (method_exists($this, '__invoke')) {
            call_user_func_array($this, $subject->getInvokeArgs());
        } else {
            throw new \Exception('Command should have at least one __invoke method');
        }
    }
1294579
public function onResolveSubject(SubjectEvent $event)
    {
        $params = $event->getParameters();

        if (array_key_exists('type', $params)) {
            if ($params['type'] == 'page') {
                $event->setSubject($this->createPageSubject());
                $event->stopPropagation();
            } elseif ($params['type'] == 'global') {
                $event->setSubject($this->createGlobalSubject());
                $event->stopPropagation();
            }
        }
    }
1157157
public function addListener($eventName, $object, $method = null)
    {
        $this->dispatcher->addListener($eventName, [$object, $method]);

        return $this;
    }
168563
public function message($to = '', $subject = '', $body = '')
    {
        $message = $this->transport->newMessage();

        if ($to) {
            $message->to($to);
        }
        if ($subject) {
            $message->subject($subject);
        }
        if ($body) {
            $message->body($body);
        }

        $message->setMailer($this);

        return $message;
    }