Commit 1083271e4fe4dbc08f2989162e9a8a3bd8521912
1 parent
9da32470
+ идентификатор IS_FRONT
Showing
3 changed files
with
22 additions
and
21 deletions
Show diff stats
backend/config/main.php
1 | <?php | 1 | <?php |
2 | + | ||
2 | $params = array_merge( | 3 | $params = array_merge( |
3 | require(__DIR__ . '/../../common/config/params.php'), | 4 | require(__DIR__ . '/../../common/config/params.php'), |
4 | require(__DIR__ . '/../../common/config/params-local.php'), | 5 | require(__DIR__ . '/../../common/config/params-local.php'), |
@@ -6,6 +7,8 @@ $params = array_merge( | @@ -6,6 +7,8 @@ $params = array_merge( | ||
6 | require(__DIR__ . '/params-local.php') | 7 | require(__DIR__ . '/params-local.php') |
7 | ); | 8 | ); |
8 | 9 | ||
10 | +define ('IS_FRONT', FALSE); | ||
11 | + | ||
9 | return [ | 12 | return [ |
10 | 'id' => 'app-backend', | 13 | 'id' => 'app-backend', |
11 | 'basePath' => dirname(__DIR__), | 14 | 'basePath' => dirname(__DIR__), |
@@ -40,15 +43,6 @@ return [ | @@ -40,15 +43,6 @@ return [ | ||
40 | 'errorHandler' => [ | 43 | 'errorHandler' => [ |
41 | 'errorAction' => 'site/error', | 44 | 'errorAction' => 'site/error', |
42 | ], | 45 | ], |
43 | - 'request'=>[ | ||
44 | - | ||
45 | - 'class' => 'common\components\Request', | ||
46 | - | ||
47 | - 'web'=> '/backend/web', | ||
48 | - | ||
49 | - 'adminUrl' => '/admin' | ||
50 | - | ||
51 | - ], | ||
52 | ], | 46 | ], |
53 | 'params' => $params, | 47 | 'params' => $params, |
54 | ]; | 48 | ]; |
common/components/LangRequest.php
@@ -5,11 +5,18 @@ namespace common\components; | @@ -5,11 +5,18 @@ namespace common\components; | ||
5 | use Yii; | 5 | use Yii; |
6 | use yii\web\Request; | 6 | use yii\web\Request; |
7 | use common\models\Language; | 7 | use common\models\Language; |
8 | +use common\models\Page; | ||
9 | +use yii\helpers\Url; | ||
8 | 10 | ||
9 | class LangRequest extends Request | 11 | class LangRequest extends Request |
10 | -{ | 12 | +{ |
11 | private $_lang_url; | 13 | private $_lang_url; |
12 | 14 | ||
15 | + public function getBaseUrl() | ||
16 | + { | ||
17 | + return str_replace ((IS_FRONT ? '/frontend/web' : '/backend/web'), '', parent::getBaseUrl()) . (IS_FRONT ? '' : '/admin'); | ||
18 | + } | ||
19 | + | ||
13 | public function getLangUrl() | 20 | public function getLangUrl() |
14 | { | 21 | { |
15 | if ($this->_lang_url === null) | 22 | if ($this->_lang_url === null) |
@@ -61,6 +68,7 @@ class LangRequest extends Request | @@ -61,6 +68,7 @@ class LangRequest extends Request | ||
61 | } | 68 | } |
62 | 69 | ||
63 | $scriptUrl = $this->getScriptUrl(); | 70 | $scriptUrl = $this->getScriptUrl(); |
71 | + | ||
64 | $baseUrl = $this->getBaseUrl(); | 72 | $baseUrl = $this->getBaseUrl(); |
65 | 73 | ||
66 | if (strpos($pathInfo, $scriptUrl) === 0) | 74 | if (strpos($pathInfo, $scriptUrl) === 0) |
@@ -84,7 +92,7 @@ class LangRequest extends Request | @@ -84,7 +92,7 @@ class LangRequest extends Request | ||
84 | { | 92 | { |
85 | $pathInfo = substr ($pathInfo, 1); | 93 | $pathInfo = substr ($pathInfo, 1); |
86 | } | 94 | } |
87 | - | 95 | + |
88 | return (string) $pathInfo; | 96 | return (string) $pathInfo; |
89 | } | 97 | } |
90 | } | 98 | } |
91 | \ No newline at end of file | 99 | \ No newline at end of file |
frontend/config/main.php
1 | <?php | 1 | <?php |
2 | -use yii\web\UrlManager; | 2 | + |
3 | $params = array_merge( | 3 | $params = array_merge( |
4 | require(__DIR__ . '/../../common/config/params.php'), | 4 | require(__DIR__ . '/../../common/config/params.php'), |
5 | require(__DIR__ . '/../../common/config/params-local.php'), | 5 | require(__DIR__ . '/../../common/config/params-local.php'), |
@@ -7,23 +7,22 @@ $params = array_merge( | @@ -7,23 +7,22 @@ $params = array_merge( | ||
7 | require(__DIR__ . '/params-local.php') | 7 | require(__DIR__ . '/params-local.php') |
8 | ); | 8 | ); |
9 | 9 | ||
10 | +define ('IS_FRONT', TRUE); | ||
11 | + | ||
10 | return [ | 12 | return [ |
11 | 'id' => 'app-frontend', | 13 | 'id' => 'app-frontend', |
12 | 'basePath' => dirname(__DIR__), | 14 | 'basePath' => dirname(__DIR__), |
15 | + //'bootstrap' => ['log', 'PageController'], | ||
13 | 'bootstrap' => ['log'], | 16 | 'bootstrap' => ['log'], |
14 | 'controllerNamespace' => 'frontend\controllers', | 17 | 'controllerNamespace' => 'frontend\controllers', |
15 | - 'components' => [ | 18 | + 'components' => [ |
19 | + //'PageController'=>[ | ||
20 | + // 'class' => 'frontend\controllers\PageController' | ||
21 | + //], | ||
16 | 'user' => [ | 22 | 'user' => [ |
17 | 'identityClass' => 'common\models\User', | 23 | 'identityClass' => 'common\models\User', |
18 | 'enableAutoLogin' => true, | 24 | 'enableAutoLogin' => true, |
19 | ], | 25 | ], |
20 | - 'request'=>[ | ||
21 | - | ||
22 | - 'class' => 'common\components\Request', | ||
23 | - | ||
24 | - 'web'=> '/frontend/web' | ||
25 | - | ||
26 | - ], | ||
27 | 'log' => [ | 26 | 'log' => [ |
28 | 'traceLevel' => YII_DEBUG ? 3 : 0, | 27 | 'traceLevel' => YII_DEBUG ? 3 : 0, |
29 | 'targets' => [ | 28 | 'targets' => [ |
@@ -41,7 +40,7 @@ return [ | @@ -41,7 +40,7 @@ return [ | ||
41 | 'enablePrettyUrl' => true, | 40 | 'enablePrettyUrl' => true, |
42 | 'showScriptName' => false, | 41 | 'showScriptName' => false, |
43 | 'rules' => [ | 42 | 'rules' => [ |
44 | - | 43 | + //'contacts' => 'page/page' |
45 | ] | 44 | ] |
46 | ], | 45 | ], |
47 | ], | 46 | ], |