class FrontEndController extends BaseController { // public $layout = 'application'; // public $menu = array(); // public $breadcrumbs = array(); }
class BackEndController extends BaseController { // public $layout = 'application'; // public $menu = array(); // public $breadcrumbs = array(); /* */ public function filters() { return array( 'accessControl', ); } /* */ public function accessRules() { return array( // array( 'allow', 'roles'=>array('admin'), ), // array( 'allow', 'actions'=>array('login'), 'users'=>array('?'), ), // array( 'deny', 'users'=>array('*'), ), ); } }
class BaseController extends CController { // - public function setNotice($message) { return Yii::app()->user->setFlash('notice', $message); } // - public function setError($message) { return Yii::app()->user->setFlash('error', $message); } }
class WebApplicationEndBehavior extends CBehavior { // private $_endName; // $_endName; public function getEndName() { return $this->_endName; } // public function runEnd($name) { $this->_endName = $name; // $this->onModuleCreate = array($this, 'changeModulePaths'); $this->onModuleCreate(new CEvent ($this->owner)); $this->owner->run(); } // onModuleCreate public function onModuleCreate($event) { $this->raiseEvent('onModuleCreate', $event); } // protected function changeModulePaths($event) { // (frontend backend) , $event->sender->controllerPath .= DIRECTORY_SEPARATOR.$this->_endName; $event->sender->viewPath .= DIRECTORY_SEPARATOR.$this->_endName; } }
... // 'behaviors'=>array( 'runEnd'=>array( 'class'=>'application.behaviors.WebApplicationEndBehavior', ), ), ...
return CMap::mergeArray( require_once(dirname(__FILE__).'/main.php'), array( // 'defaultController' => 'posts', // 'components'=>array( // 'user'=>array( 'loginUrl'=>array('/users/login'), ), // mailer 'mailer'=>array( 'pathViews' => 'application.views.backend.email', 'pathLayouts' => 'application.views.email.backend.layouts' ), ), ) );
// $yii = dirname(__FILE__).'/../yii/framework/yii.php'; $config = dirname(__FILE__).'/protected/config/frontend.php'; // ? defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3); // require_once($yii); // WebApplicaitonEndBehavior, , Yii::createWebApplication($config)->runEnd('frontend');
// $yii = dirname(__FILE__).'/../yii/framework/yii.php'; $config = dirname(__FILE__).'/protected/config/backend.php'; // ? defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3); // require_once($yii); // WebApplicaitonEndBehavior, , Yii::createWebApplication($config)->runEnd('backend');
Source: https://habr.com/ru/post/117457/
All Articles