From 1083271e4fe4dbc08f2989162e9a8a3bd8521912 Mon Sep 17 00:00:00 2001 From: andryeyev Date: Thu, 19 Nov 2015 10:31:51 +0200 Subject: [PATCH] + идентификатор IS_FRONT --- backend/config/main.php | 12 +++--------- common/components/LangRequest.php | 12 ++++++++++-- frontend/config/main.php | 19 +++++++++---------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/backend/config/main.php b/backend/config/main.php index 40a62d5..e4ff8c7 100644 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -1,4 +1,5 @@ 'app-backend', 'basePath' => dirname(__DIR__), @@ -40,15 +43,6 @@ return [ 'errorHandler' => [ 'errorAction' => 'site/error', ], - 'request'=>[ - - 'class' => 'common\components\Request', - - 'web'=> '/backend/web', - - 'adminUrl' => '/admin' - - ], ], 'params' => $params, ]; diff --git a/common/components/LangRequest.php b/common/components/LangRequest.php index 60949f9..6aece05 100644 --- a/common/components/LangRequest.php +++ b/common/components/LangRequest.php @@ -5,11 +5,18 @@ namespace common\components; use Yii; use yii\web\Request; use common\models\Language; +use common\models\Page; +use yii\helpers\Url; class LangRequest extends Request -{ +{ private $_lang_url; + public function getBaseUrl() + { + return str_replace ((IS_FRONT ? '/frontend/web' : '/backend/web'), '', parent::getBaseUrl()) . (IS_FRONT ? '' : '/admin'); + } + public function getLangUrl() { if ($this->_lang_url === null) @@ -61,6 +68,7 @@ class LangRequest extends Request } $scriptUrl = $this->getScriptUrl(); + $baseUrl = $this->getBaseUrl(); if (strpos($pathInfo, $scriptUrl) === 0) @@ -84,7 +92,7 @@ class LangRequest extends Request { $pathInfo = substr ($pathInfo, 1); } - + return (string) $pathInfo; } } \ No newline at end of file diff --git a/frontend/config/main.php b/frontend/config/main.php index 096b756..20034bb 100644 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -1,5 +1,5 @@ 'app-frontend', 'basePath' => dirname(__DIR__), + //'bootstrap' => ['log', 'PageController'], 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\controllers', - 'components' => [ + 'components' => [ + //'PageController'=>[ + // 'class' => 'frontend\controllers\PageController' + //], 'user' => [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => true, ], - 'request'=>[ - - 'class' => 'common\components\Request', - - 'web'=> '/frontend/web' - - ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ @@ -41,7 +40,7 @@ return [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ - + //'contacts' => 'page/page' ] ], ], -- libgit2 0.21.4