* @throws InvalidConfigException if invalid normalization action is used.
* @throws UrlNormalizerRedirectException if normalization requires redirection.
* @throws NotFoundHttpException if normalization suggests action matching route does not exist.
*/
public function normalizeRoute($route)
{
if ($this->action === null) {
return $route;
} elseif ($this->action === static::ACTION_REDIRECT_PERMANENT || $this->action === static::ACTION_REDIRECT_TEMPORARY) {
throw new UrlNormalizerRedirectException([$route[0]] + $route[1], $this->action);
} elseif ($this->action === static::ACTION_NOT_FOUND) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
} elseif (is_callable($this->action)) {
return call_user_func($this->action, $route, $this);
}
throw new InvalidConfigException('Invalid normalizer action.');
}
return false;
}
}
if ($normalized) {
// pathInfo was changed by normalizer - we need also normalize route
return $this->normalizer->normalizeRoute([$pathInfo, []]);
}
return [$pathInfo, []];
}
Yii::debug('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__);
/**
* Parsing request url
*
*/
public static function parseUrl()
{
$url = Yii::$app->urlManager->parseRequest(Yii::$app->request);
$params = Yii::$app->request->get();
$url[1] = ArrayHelper::merge($url[1], $params);
return $url;
}
}
if(!Yii::$app->user->isGuest){
$user = Users::findOne(['id' => Yii::$app->user->id]);
$user->language = $lang;
$user->save();
}
} else {
$langUrl = StringHelper::explode(Url::parseUrl()[0], '/')[0];
if(strlen($langUrl) != 2){
$langUrl = null;
}
//Si tenemos idioma en la url prima este idioma
Yii::$app->params['missingTranslations'] = []; Yii::$app->params['webConfigFrontend'] = WebConfig::find()->where(['app' => 'frontend'])->one(); Yii::$app->params['webConfigBackend'] = WebConfig::find()->where(['app' => 'backend'])->one(); Yii::$app->name = Yii::$app->params['webConfigFrontend']->company; ModulesController::load(); Yii::$app->languages->setLanguage(); Yii::$app->params['defaultCurrency'] = Currencies::find()->where(['default' => 1])->one(); Yii::$app->currencies->setCurrencyById(); ModulesController::initializeRoutes(); Yii::$app->setComponents([
* @throws \yii\base\InvalidConfigException
* @throws \yii\base\InvalidRouteException
* @throws \yii\console\Exception
*/
public static function load()
{
parent::load();
Yii::$app->homeUrl = Url::to([Yii::$app->params['webConfigFrontend']->homePage]);
ModulesController::siteMap();
if(Yii::$app->params['webConfigFrontend']->maintenance and Yii::$app->user->isGuest){
// Cargamos la configuración general
switch(Yii::$app->id) {
case 'backend':
BackendSystem::load();
break;
case 'frontend':
FrontendSystem::load();
break;
case 'api':
ApiSystem::load();
break;
}
*/
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.
$appConf = yii\helpers\ArrayHelper::merge( $appConf, require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main-local.php') ); } $application = new common\yii2\web\Application($appConf); $application->run();