Returns the current application.

@param Event $event

@return \BackBee\BBApplication
199392
private static function getApplication(Event $event)
    {
        if (null === self::$_application) {
            if (null !== $event->getDispatcher()) {
                self::$_application = $event->getDispatcher()->getApplication();
            }
        }

        return self::$_application;
    }
1151409
public static function fromEvent(Event $event)
    {
        $io = NutStyle::fromComposer($event->getIO());
        $options = Options::fromEvent($event);

        return new static($io, $options);
    }
213131
protected function getPayloadFromEvent($event)
    {
        if (method_exists($event, 'broadcastWith')) {
            return $event->broadcastWith();
        }

        $payload = array();

        //
        $reflection = new ReflectionClass($event);

        foreach ($reflection->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
            $key = $property->getName();

            $value = $property->getValue($event);

            $payload[$key] = $this->formatProperty($value);
        }

        return $payload;
    }
32973
public function dispatchEvent(\Symfony\Component\EventDispatcher\Event $event)
    {
        $container = \OxidEsales\EshopCommunity\Internal\Application\ContainerFactory::getInstance()->getContainer();
        $dispatcher = $container->get(EventDispatcherInterface::class);
        return $dispatcher->dispatch($event::NAME, $event);
    }
935320
public static function process($event)
    {
        // Link Lead with User
        if ($event->account_linking->status === 'linked') {
            $authorization_code = $event->account_linking->authorization_code;
            $user_id = str_replace('user_id:', '', $authorization_code);
            
            return self::linkWithExistingUser($event->sender->id, $user_id);
        } // Unlink, Logout user
        
        return self::unlinkWithExistingUser($event->sender->id);
    }
1101721
protected function getEventObject($event, $data)
    {
        $eventClass = new ReflectionClass($this->getEventClass($event));

        return $eventClass->newInstanceArgs($data);
    }
843340
private function getEventObject(Event $event)
    {
        // get the service name
        list ($serviceName) = explode(":", $event->getRequest()->get('_controller'));

        // get the controller which handles this request
        if ($this->container->has($serviceName)) {
            $controller = $this->container->get($serviceName);
            $restEvent = $this->restEvent;
            $restEvent->setRequest($event->getRequest());
            $restEvent->setResponse($this->response);
            $restEvent->setController($controller);

            $returnEvent = $restEvent;
        } else {
            $returnEvent = $event;
        }

        return $returnEvent;
    }
184230
protected static function getProjectDir(Event $event): string
    {
        return $event->getComposer()->getConfig()->get('vendor-dir')
            . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
    }
55422
public function dispatch(Event $event): Event
    {
        return $this->getRouter()->route(new Context($event->name(), $event));
    }
1363062
public function getEvent(string $event)
    {
        $class = (string)$this->sprintf(':namespace\Event\:event', __NAMESPACE__, $event);

        if (class_exists($class)) {
            return new $class($this);
        }

        return null;
    }
392657
public function getCustom($event, $properties = [])
    {
        $properties = empty($properties) ? [] : [PayloadProperties::PROPERTIES => $properties];

        return $this->getTrackPayload($event, $properties);
    }
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);
        }
    }
2628
protected function getValue($event)
    {
        if ($this->value === null && Yii::getApp()->has('user')) {
            $userId = Yii::getApp()->get('user')->id;
            if ($userId === null) {
                return $this->getDefaultValue($event);
            }

            return $userId;
        }

        return parent::getValue($event);
    }
460029
public function dispatch(Event $event)
        {
            $message = sprintf(self::FMT_INF_DISPATCHING, $event->getId(), count($this->subscriptions));
            $this->logger->info($message);

            $dispatchCount = 0;

            foreach ($this->subscriptions as $subscription) {
                $result = $this->tryDispatch($subscription, $event);

                $dispatchCount += (int)$result;
            }

            $message = sprintf(self::FMT_INF_DISPATCHED, $event->getId(), $dispatchCount);
            $this->logger->info($message);

            return $dispatchCount;
        }
259026
protected function getPayloadFromEvent($event)
    {
        if (method_exists($event, 'broadcastWith')) {
            return array_merge(
                $event->broadcastWith(), ['socket' => data_get($event, 'socket')]
            );
        }

        $payload = [];

        foreach ((new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
            $payload[$property->getName()] = $this->formatProperty($property->getValue($event));
        }

        unset($payload['broadcastQueue']);

        return $payload;
    }
985785
protected function getCachedEvent($event)
    {
        $path = $event->getResource()->getPath();

        return isset($this->eventCache[$path])
            ? $this->eventCache[$path]
            : $this->eventCache[$path] = Carbon::now()->subDay();
    }
937261
public static function onApplicationReady(Event $event)
    {
        $app = $event->getTarget();

        $twigAdapter = $app->getRenderer()->getAdapter('twig');
        if (null === $twigAdapter) {
            return;
        }

        foreach ($app->getContainer()->findTaggedServiceIds('twig.extension') as $id => $data) {
            $twigAdapter->addExtension($app->getContainer()->get($id));
        }
    }