public function bootstrap($app) { $languages = Language::find()->all(); $languages_iso = ArrayHelper::getColumn($languages, 'iso'); $this->supportedLanguages = $languages_iso; if(!Yii::$app->user->identity){ $supportedLangs = $this->supportedLanguages; $languages = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); $browserMainLang = $languages[0]; $browserMainLang = str_replace('_', '-', $browserMainLang); $browserMainLangShort = explode('-', strtolower($browserMainLang)); foreach ($supportedLangs as $supportedLang) { $supportedL = explode('-', strtolower($supportedLang)); $supportedShortLangs[] = $supportedL[0]; }
$languages = Language::find()->all(); $languages_iso = ArrayHelper::getColumn($languages, 'iso'); $this->supportedLanguages = $languages_iso; if(!Yii::$app->user->identity){ $supportedLangs = $this->supportedLanguages; $languages = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); $browserMainLang = $languages[0]; $browserMainLang = str_replace('_', '-', $browserMainLang); $browserMainLangShort = explode('-', strtolower($browserMainLang)); foreach ($supportedLangs as $supportedLang) { $supportedL = explode('-', strtolower($supportedLang));
if (!isset($component)) { $component = Yii::createObject($mixed); } if ($component instanceof BootstrapInterface) { Yii::debug('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__); $component->bootstrap($this); } else { Yii::debug('Bootstrap with ' . get_class($component), __METHOD__); } } }
protected function bootstrap() { $request = $this->getRequest(); Yii::setAlias('@webroot', dirname($request->getScriptFile())); Yii::setAlias('@web', $request->getBaseUrl()); parent::bootstrap(); } /** * Handles the specified request. * @param Request $request the request to be handled * @return Response the resulting response
/** * {@inheritdoc} */ public function init() { $this->state = self::STATE_INIT; $this->bootstrap(); } /** * Initializes extensions and executes bootstrap components. * This method is called by [[init()]] after the application has been fully configured. * If you override this method, make sure you also call the parent implementation.
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$this->state = self::STATE_BEGIN; $this->preInit($config); $this->registerErrorHandler($config); Component::__construct($config); } /** * Pre-initializes the application. * This method is called at the beginning of the application constructor. * It initializes several important application properties.
$config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', ]; } (new yii\web\Application($config))->run();