File: /home/emblazeone/www/master-template/frontend/controllers/BaseController.php
<?php
namespace frontend\controllers;
use backend\modules\sites\models\Sites;
use frontend\models\LoginForm;
use yii\web\Controller;
use yii\web\HttpException;
use yii\web\NotFoundHttpException;
class BaseController extends Controller
{
public $site;
public $loginForm=false;
public function beforeAction($action)
{
$name = trim($_SERVER['SERVER_NAME']);
$this->site = Sites::findOne(['url' => $name, 'status' => Sites::STATUS_ACTIVE]);
if ( $action->id == 'error' ) {
if (!$this->site) $this->layout='error';
return true;
}
if (!$this->site) throw new NotFoundHttpException('Page not found.');
$this->loginForm=new LoginForm();
return parent::beforeAction($action); // TODO: Change the autogenerated stub
}
}