@return ApplicationInterface

@throws BBException
188586
private function initEntityManager()
    {
        if (!$this->container->getDefinition('em')->isSynthetic()) {
            return;
        }

        if (null === $doctrineConfig = $this->getConfig()->getRawSection('doctrine')) {
            throw new BBException('None database configuration found');
        }

        if (!isset($doctrineConfig['dbal'])) {
            throw new BBException('None dbal configuration found');
        }

        if (!isset($doctrineConfig['dbal']['proxy_ns'])) {
            $doctrineConfig['dbal']['proxy_ns'] = 'Proxies';
        }

        if (!isset($doctrineConfig['dbal']['proxy_dir'])) {
            $doctrineConfig['dbal']['proxy_dir'] = $this->getCacheDir().'/'.'Proxies';
        }

        if (isset($doctrineConfig['orm'])) {
            $doctrineConfig['dbal']['orm'] = $doctrineConfig['orm'];
        }

        // Init ORM event
        $r = new \ReflectionClass('Doctrine\ORM\Events');
        $definition = new Definition('Doctrine\Common\EventManager');
        $definition->addMethodCall('addEventListener', [$r->getConstants(), new Reference('doctrine.listener')]);
        $this->container->setDefinition('doctrine.event_manager', $definition);

        try {
            $loggerId = 'logging';

            if ($this->isDebugMode()) {
                // doctrine data collector
                $this->getContainer()->get('data_collector.doctrine')->addLogger(
                    'default',
                    $this->getContainer()->get('doctrine.dbal.logger.profiling')
                );
                $loggerId = 'doctrine.dbal.logger.profiling';
            }

            $definition = new Definition('Doctrine\ORM\EntityManager', [
                $doctrineConfig['dbal'],
                new Reference($loggerId),
                new Reference('doctrine.event_manager'),
                new Reference('service_container'),
            ]);
            $definition->setFactory(['BackBee\Util\Doctrine\EntityManagerCreator', 'create']);
            $this->container->setDefinition('em', $definition);

            $this->debug(sprintf('%s(): Doctrine EntityManager initialized', __METHOD__));
        } catch (\Exception $e) {
            $this->warning(sprintf('%s(): Cannot initialize Doctrine EntityManager', __METHOD__));
        }

        return $this;
    }
1359719
public function getRequest(): RequestInterface
    {
        if (!$this->request) {
            $this->resolveOptions();
            $this->request = $this->createRequest();
        }

        return parent::getRequest();
    }
681630
public function getConnection():ConnectionInterface
    {
        if (App::isCoContext()) {
            $connection = $this->getConnectionByChannel();
        } else {
            $connection = $this->getConnectionByQueue();
        }

        if ($connection->check() == false) {
            $connection->reconnect();
        }

        $this->addContextConnection($connection);
        return $connection;
    }
1184115
public function getApplication()
    {
        if (!($this->_io instanceof IOInterface)) {
            throw new \RuntimeException('Bootstrapper instance requires IOInterface instance. Please call setIO() first.');
        }

        if (!$this->_bootstrapped) {
            $this->_bootstrap();
        }

        if (!($this->_application instanceof Application))
        {
            $options = array(
                'root_user' => $this->_credentials['username'],
                'loglevel'  => $this->_verbosity,
                'platform'  => Util::isJoomlatoolsPlatform()
            );

            try
            {
                $this->_application = new Application($options);
                $this->_application->authenticate($this->_credentials);
            }
            catch (\Exception $ex)
            {
                $this->_io->write("<error>Failed to initialize the Joomla application</error>");

                if ($this->_io->isVerbose()) {
                    $this->_io->write($ex->getMessage());
                }

                if ($this->_io->isDebug()) {
                    throw $ex;
                }

                $this->_application = false;
            }
        }

        return $this->_application;
    }
510311
public static function getApplicationList() {
        if (self::$_application) {
            return self::$_application;
        }

        self::$_application = self::_getList('application');

        return self::$_application;
    }
1123497
protected function addFrameworkConfigs(): ApplicationBuilder
    {
        foreach ($this->getFrameworkConfigs() as $loader) {
            $loader = new $loader;
            if ($loader instanceof LoaderInterface) {
                $this->addConfig($loader);
            }
        }

        return $this;
    }
1167660
private function getApp()
	{
		$stack = $this->resolve('requeststack');

		if ($request = $stack->top())
		{
			$app = $request->getApplication();
		}
		else
		{
			$app = $this->resolve('application::__main');
		}

		return $app;
	}
1028728
public function setApplication(ApplicationInterface $application)
    {
        $this->setParam('application', $application);
        $this->application = $application;
        return $this;
    }
652504
protected function getContainer(): ContainerInterface
    {
        if (null === $this->container) {
            $app = $this->getApplication();

            if (!$app instanceof Application) {
                throw new \RuntimeException('Sculpin Application not found!');
            }

            $this->container = $app->getKernel()->getContainer();
        }

        return $this->container;
    }
857732
public function initialize()
    {
        // Create the application object
        $app = new Application;

        $this->setEnvironment($app);
        $this->registerConfig($app);

        // Handle init config
        $initConfig = $app['config']->load('init');

        if ($initConfig['debug']) {
            Debug::enable();
            $app['debug'] = true;
        }

        return $app;
    }
1374897
public function getObjectManager(): ObjectManagerInterface
    {
        if (!isset($this->earlyInstances[ObjectManagerInterface::class])) {
            debug_print_backtrace();
            throw new FlowException('The Object Manager is not available at this stage of the bootstrap run.', 1301120788);
        }
        return $this->earlyInstances[ObjectManagerInterface::class];
    }
433530
protected function getFreshApplication()
    {
        return tap(require $this->laravel->bootstrapPath().'/app.php', function ($app) {
            $app->make(ConsoleKernelContract::class)->bootstrap();
        });
    }
318963
public final function run(): ResponseInterface
    {
        try {
            $this->prepare();
            try {
                $body = "";
                $container = $this->getContainer();
                $controller = $this->getController($container);
                $body = $controller->execute($container);
                unset($container);
                $response = $controller->getResponse();
                unset($controller);
                return $this->send($response, $body);
            } catch (RuntimeException $e) {
                trigger_error("Run warning: " . $e->getMessage(), E_USER_WARNING);
                unset($container);
                return $this->send($controller->getResponse(), $body);
            } catch (RouterException $e) {
                trigger_error("Run notice: " . $e->getMessage(), E_USER_NOTICE);
                return $this->send($this->getResponse()->withStatus(404), $body);
            } catch (DispatcherException $e) {
                trigger_error("Run error: " . $e->getMessage(), E_USER_ERROR);
                return $this->send($this->getResponse()->withStatus(500), $body);
            }
        } catch (RuntimeException $e) {
            throw new RuntimeException("Can't run application: " . $e->getMessage());
        }
    }
693728
public function getAdapter()
    {
        if (is_null($this->adapter) || ! $this->adapter instanceof AdapterInterface) {
            $class = '\\Wslim\\Db\Adapter\\' . $this->options['adapter'] . 'Adapter';
            if (!class_exists($class)) {
                throw new DbException('database adapter is not exists:' . $class);
            }
            
            $this->adapter  =   new $class($this->options);
        }
        
        return $this->adapter;
    }
1225670
public function getApplication()
    {
        $application = $this->application;

        if ($application instanceof Closure) {
            return $application();
        } elseif (is_string($application)) {
            /** @noinspection PhpIncludeInspection */
            return require $application;
        }

        return $application;
    }
118416
public function getApplication() {
		if (!is_null($this->session)) {
			return $this->session->getApplication();
		} else {
			return $this->context->getSystem()->getApplication();
		}
	}
274785
public function onInstallPlugin()
    {
        try {
            if (!$code = trim(post('code'))) {
                throw new ApplicationException(Lang::get('system::lang.install.missing_plugin_name'));
            }

            $manager = UpdateManager::instance();
            $result = $manager->requestPluginDetails($code);

            if (!isset($result['code']) || !isset($result['hash'])) {
                throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
            }

            $name = $result['code'];
            $hash = $result['hash'];
            $plugins = [$name => $hash];
            $plugins = $this->appendRequiredPlugins($plugins, $result);

            /*
             * Update steps
             */
            $updateSteps = $this->buildUpdateSteps(null, $plugins, [], true);

            /*
             * Finish up
             */
            $updateSteps[] = [
                'code'  => 'completeInstall',
                'label' => Lang::get('system::lang.install.install_completing'),
            ];

            $this->vars['updateSteps'] = $updateSteps;

            return $this->makePartial('execute');
        }
        catch (Exception $ex) {
            $this->handleError($ex);
            return $this->makePartial('plugin_form');
        }
    }