Set current theme for request.

@param  \Illuminate\Contracts\Foundation\Application  $app

@return void
162181
protected function setCurrentTheme(Application $app)
    {
        $memory = $app->make('antares.memory')->makeOrFallback();
        $app->make('antares.theme')->setTheme($memory->get('site.theme.frontend'));

        $events = $app->make('events');

        $events->listen(AdminStarted::class, function () use ($app, $memory, $events) {
            $theme = $app->make('antares.theme');
            if (auth()->isAny(['member'])) {
                $theme->setTheme($memory->get('site.theme.frontend'));
            } else {
                $theme->setTheme($memory->get('site.theme.backend'));
            }
        });

        $events->listen('composing: *', function () use ($app) {
            $app->make('antares.theme')->boot();
        });
    }
529854
final protected function resolveApplicationBindings($app): void
    {
        foreach ($this->overrideApplicationBindings($app) as $original => $replacement) {
            $app->bind($original, $replacement);
        }
    }
1089834
public function boot(Application $app)
    {

        // Register our filters to use
        if (isset($app['assetic.filters']) && is_callable($app['assetic.filters'])) {
            $app['assetic.filters']($app['assetic.filter_manager']);
        }

        /**
         * Writes down all lazy asset manager and asset managers assets
         */
        $app->after(function () use ($app) {
            // Boot assetic
            $assetic = $app['assetic'];

            if (!isset($app['assetic.options']['auto_dump_assets']) ||
                !$app['assetic.options']['auto_dump_assets']) {
                return;
            }
            $helper = $app['assetic.dumper'];
            if (isset($app['twig'])) {
                $helper->addTwigAssets();
            }
            $helper->dumpAssets();
        });
    }
221377
public function setApplication($application) {
        $this->application = $application;
        foreach($this->translations as $locale => $translations) {
            foreach($translations as $translation) {
                $translation->translation_key = $this;
            }
        }
    }
937988
public function bootstrap(Application $app)
    {
        foreach ($app['config']->get('supports', []) as $feature => $value)
        {
            if ($value === 'automatic-feed-links')
            {
                add_theme_support($value);
            }
            else
            {
                add_theme_support($feature, $value);
            }
        }
    }
977115
public function onConstruct($app)
    {
        //if not null
        if (!is_null($app)) {
            $key = $this->settingsKey;
            $this->$key = $app;
        }
    }
1247932
protected function setEnvironment(Application $app)
    {
        // Define acceptable environments
        $environments = array(
            'production',
            'staging',
            'qa',
            'testing',
            'development',
            'beta',
        );

        if (! isset($_SERVER['APP_ENV'])) {
            throw new \Exception('Missing \'APP_ENV\' environment variable');
        }

        if (! in_array($_SERVER['APP_ENV'], $environments)) {
            throw new \Exception('Invalid \'APP_ENV\' environment variable: \'' + $_SERVER['APP_ENV'] +'\'');
        }

        $app['environment'] = $_SERVER['APP_ENV'];
    }
285237
public function setApp(Application $app)
    {
        $this->app = $app;
        AppSingleton::set($app);
        $this->pathResolver = $app['path_resolver'];

        // if RM is passed directly into Application c.v.a won't be set
        // but if called later then we don't want to override the value if someone else has changed it,
        // unless disableApacheChecks has been called.
        $default = true;
        if (isset($this->app['config.validator.apache_enabled'])) {
            $default = $this->app['config.validator.apache_enabled'];
        }
        $this->app['config.validator.apache_enabled'] = function () use ($default) {
            return $this->disableApacheChecks ? false : $default;
        };
    }
230235
public function bootstrap(Application $app)
	{
		$url = $app['config']->get('app.url', 'http://localhost');

		$app->instance('request', Request::create($url, 'GET', [], [], [], $_SERVER));
	}
466338
public function bootstrap($app)
    {
        if ($app instanceof WebApplication) {
            $this->addUrlManagerRules($app);
            $this->setPodiumLogTarget($app);
        } elseif ($app instanceof ConsoleApplication) {
            $this->controllerNamespace = 'bizley\podium\console';
        }
    }
1343421
public function bootstrap($app)
    {
        if ($this->isBootstrapI18n) {
            $this->bootstrapI18n($app);
        }

        $bootstraps = [];
        foreach ($this->getDepends() as $key => $depends) {
            foreach ($depends as $name => $depend) {
                switch ($key) {
                    case 'bootstrap':
                        $bootstraps[$name] = $depend;
                    break;
                    case 'modules':
                        if (!$app->hasModule($name)) {
                            $app->setModule($name, $depend);
                        }
                    break;
                    case 'components':
                        if (in_array($name, self::CORE_COMPONENTS) || !$app->has($name)) {
                            if (in_array($name, self::CORE_COMPONENTS)) {
                                if (!empty(self::$coreComponents[$name])) {
                                    break;
                                }

                                self::$coreComponents[$name] = true;
                            }

                            $app->set($name, $depend);
                        }
                    break;
                }
            }
        }

        foreach ($bootstraps as $bootstrapKey => $bootstrap) {
            if (is_string($bootstrap)) {
                $module = $app->getModule($bootstrap);
                if ($module instanceof BootstrapInterface) {
                    $module->bootstrap($app);
                }
            } else if (is_callable($bootstrap)) {
                if (in_array($bootstrapKey, self::$boostrapped)) {
                    continue;
                }

                $bootstrap();
                self::$boostrapped[] = $key;
            } else {
                $bootstrapKey = $bootstrap['class'];
                if (array_key_exists('moduleId', $bootstrap)) {
                    $bootstrapKey .= '-' . $bootstrap['moduleId'];
                }

                if (in_array($bootstrapKey, self::$boostrapped)) {
                    continue;
                }

                self::$boostrapped[] = $bootstrap['class'];
                $bootstrap = \yii::createObject($bootstrap);
                $bootstrap->bootstrap($app);
            }
        }
    }
687848
public function bootstrap(Application $app)
    {
        $items = [];

        $app->instance('config', $config = new Repository($items));

        $this->loadConfigurationFiles($app, $config);

        mb_internal_encoding('UTF-8');
    }
714384
public function setApp(PhrestAPI $app)
  {
    $this->app = $app;
    $this->app->isInternalRequest = true;

    return $this;
  }
730428
public function bootstrap(Application $app)
    {
        if ($app->make('orchestra.extension.status')->is('safe')) {
            Messages::extend(function (MessageBag $messages) {
                $messages->add('info', \trans('orchestra/foundation::response.safe-mode'));
            });
        }
    }
623626
public function theme_should_be_activated( $theme )
	{
		$theme = $this->replace_variables( $theme );
		$current_theme = $this->get_current_theme();

		if ( $theme !== $current_theme ) {
			throw new \Exception( sprintf(
				"The current theme is %s, but it should be %s",
				$current_theme,
				$theme
			) );
		}
	}
196827
public function register(Application $app)
    {
        $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, $app) {
            $twig->setCache($app['cache.path'] . '/twig');

            $paths = [];

            if (file_exists($app['plugin.path'] . '/twig-paths.php')) {
                $paths = require $app['plugin.path'] . '/twig-paths.php';
            }

            if ($app['browser']->isTablet() || $app['browser']->isMobile()) {
                $paths[] = $app['root.path'] . '/config/templates/mobile';
                $paths[] = $app['root.path'] . '/templates/mobile';
                $paths['phraseanet'] = $app['root.path'] . '/config/templates/mobile';
                $paths['phraseanet'] = $app['root.path'] . '/templates/mobile';
            }

            $paths[] = $app['root.path'] . '/config/templates/web';
            $paths[] = $app['root.path'] . '/templates/web';
            $paths['phraseanet'] = $app['root.path'] . '/config/templates/web';
            $paths['phraseanet'] = $app['root.path'] . '/templates/web';

            foreach ($paths as $namespace => $path) {
                if (!is_int($namespace)) {
                    $app['twig.loader.filesystem']->addPath($path, $namespace);
                } else {
                    $app['twig.loader.filesystem']->addPath($path);
                }
            }

            $twig->addGlobal('current_date', new \DateTime());

            $this->registerExtensions($twig, $app);
            $this->registerFilters($twig, $app);

            return $twig;
        }));
    }
599518
protected function defineControllers(Application $app)
    {
        $this->createController('/payone', 'payone-index', 'Payone', 'index', 'index')->method('POST');
        $this->createController('/payone/getfile', 'payone-getfile', 'payone', 'index', 'getFile')->method('GET|POST');
        $this->createController('/payone/regular-redirect-payment-cancellation', 'payone-cancel-redirect', 'Payone', 'index', 'cancelRedirect')->method('GET');
        $this->createController('/payone/getinvoice', 'payone-getinvoice', 'Payone', 'index', 'getInvoice')->method('GET');
        $this->createController(
            static::EXPRESS_CHECKOUT_BUTTON_PATH,
            static::EXPRESS_CHECKOUT_BUTTON,
            'payone',
            'expressCheckout',
            'checkoutWithPaypalButton'
        )->method('GET');

        $this->createController(
            static::EXPRESS_CHECKOUT_INIT_PATH,
            static::EXPRESS_CHECKOUT_INIT,
            'payone',
            'expressCheckout',
            'initPaypalExpressCheckout'
        )->method('GET');

        $this->createController(
            static::EXPRESS_CHECKOUT_LOAD_DETAILS_PATH,
            static::EXPRESS_CHECKOUT_LOAD_DETAILS,
            'payone',
            'expressCheckout',
            'loadPaypalExpressCheckoutDetails'
        )->method('GET');

        $this->createController(
            static::EXPRESS_CHECKOUT_FAILURE_PATH,
            static::EXPRESS_CHECKOUT_FAILURE,
            'payone',
            'expressCheckout',
            'failure'
        )->method('GET');

        $this->createController(
            static::EXPRESS_CHECKOUT_BACK_PATH,
            static::EXPRESS_CHECKOUT_BACK,
            'payone',
            'expressCheckout',
            'back'
        )->method('GET');
    }