diff --git a/common/modules/blog/controllers/PostController.php b/common/modules/blog/controllers/PostController.php index 966287d..64bd745 100644 --- a/common/modules/blog/controllers/PostController.php +++ b/common/modules/blog/controllers/PostController.php @@ -11,16 +11,16 @@ use common\modules\blog\repositories\read\BlogPostReadRepository; use common\modules\blog\repositories\read\BlogTagReadRepository; use common\modules\blog\services\BlogCommentService; use core\entities\Meta; +use frontend\components\FrontendController; use Yii; use yii\base\Security; use yii\data\ActiveDataProvider; use yii\helpers\FileHelper; use yii\helpers\Json; -use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\AccessControl; -class PostController extends Controller +class PostController extends FrontendController { public $layout = 'blog'; diff --git a/common/modules/pages/controllers/PageController.php b/common/modules/pages/controllers/PageController.php index 5608598..94fb026 100644 --- a/common/modules/pages/controllers/PageController.php +++ b/common/modules/pages/controllers/PageController.php @@ -3,12 +3,12 @@ namespace common\modules\pages\controllers; use common\modules\pages\repositories\read\PageReadRepository; -use yii\web\Controller; +use frontend\components\FrontendController; use yii\web\NotFoundHttpException; use yii\filters\AccessControl; -class PageController extends Controller +class PageController extends FrontendController { private $pages; diff --git a/frontend/bootstrap/SetUp.php b/frontend/bootstrap/SetUp.php index 32ab8be..b5ac060 100644 --- a/frontend/bootstrap/SetUp.php +++ b/frontend/bootstrap/SetUp.php @@ -33,19 +33,5 @@ class SetUp implements BootstrapInterface '<_c:[\w\-]+>/<_a:[\w-]+>' => '<_c>/<_a>', '<_c:[\w\-]+>//<_a:[\w\-]+>' => '<_c>/<_a>', ]); - - // Set site theme - $theme = isset($app->params['settings']['design']['theme']) ? $app->params['settings']['design']['theme'] : 'start'; - - $app->view->theme = new Theme([ - 'basePath' => '@webroot/themes/' . $theme, - 'baseUrl' => '@web/themes/' . $theme, - 'pathMap' => [ - '@common/modules' => '@webroot/themes/' . $theme . '/modules', - '@frontend/views' => '@webroot/themes/' . $theme, - '@frontend/widgets' => '@webroot/themes/' . $theme . '/widgets', - ], - - ]); } } \ No newline at end of file diff --git a/frontend/components/FrontendController.php b/frontend/components/FrontendController.php new file mode 100644 index 0000000..ffaf311 --- /dev/null +++ b/frontend/components/FrontendController.php @@ -0,0 +1,32 @@ +params['settings']['design']['theme']) ? Yii::$app->params['settings']['design']['theme'] : 'start'; + + Yii::$app->view->theme = new Theme([ + 'basePath' => '@webroot/themes/' . $theme, + 'baseUrl' => '@web/themes/' . $theme, + 'pathMap' => [ + '@common/modules' => '@webroot/themes/' . $theme . '/modules', + '@frontend/views' => '@webroot/themes/' . $theme, + '@frontend/widgets' => '@webroot/themes/' . $theme . '/widgets', + ], + + ]); + } +} \ No newline at end of file diff --git a/frontend/controllers/ContactController.php b/frontend/controllers/ContactController.php index 30138a8..9a27b76 100644 --- a/frontend/controllers/ContactController.php +++ b/frontend/controllers/ContactController.php @@ -2,11 +2,11 @@ namespace frontend\controllers; use core\services\ContactService; +use frontend\components\FrontendController; use Yii; use core\forms\ContactForm; -use yii\web\Controller; -class ContactController extends Controller +class ContactController extends FrontendController { public $layout = 'contacts'; diff --git a/frontend/controllers/PostController.php b/frontend/controllers/PostController.php index c103044..d157834 100644 --- a/frontend/controllers/PostController.php +++ b/frontend/controllers/PostController.php @@ -8,13 +8,13 @@ use core\repositories\post\read\PostCategoryReadRepository; use core\repositories\post\read\PostReadRepository; use core\repositories\post\read\PostTagReadRepository; use core\services\post\PostCommentService; +use frontend\components\FrontendController; use Yii; use yii\data\ActiveDataProvider; -use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\AccessControl; -class PostController extends Controller +class PostController extends FrontendController { public $layout = 'post'; diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 249ee93..3500b86 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -3,16 +3,16 @@ namespace frontend\controllers; use core\forms\SubscribeForm; use core\services\newsletter\Newsletter; +use frontend\components\FrontendController; use yii\filters\VerbFilter; use yii\filters\AccessControl; use frontend\components\SiteAccess; use Yii; -use yii\web\Controller; /** * Site controller */ -class SiteController extends Controller +class SiteController extends FrontendController { public $newletter; @@ -28,7 +28,7 @@ class SiteController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'only' => ['subscribe'], 'rules' => [ [ @@ -38,12 +38,12 @@ class SiteController extends Controller ], ], 'verbs' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => [ 'logout' => ['post'], ], ], - SiteAccess::className(), + SiteAccess::class, ]; } diff --git a/frontend/controllers/account/ProfileController.php b/frontend/controllers/account/ProfileController.php index 8301483..6e1d607 100644 --- a/frontend/controllers/account/ProfileController.php +++ b/frontend/controllers/account/ProfileController.php @@ -7,7 +7,7 @@ namespace frontend\controllers\account; -use yii\web\Controller; +use frontend\components\FrontendController; use core\services\user\ProfileService; use core\forms\user\ProfileEditForm; use core\entities\user\User; @@ -15,7 +15,7 @@ use yii\web\NotFoundHttpException; use yii\filters\AccessControl; use Yii; -class ProfileController extends Controller +class ProfileController extends FrontendController { public $layout = 'profile'; @@ -31,7 +31,7 @@ class ProfileController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'only' => ['index'], 'rules' => [ [