Now that we have registered our application with Yii and defined our custom routes, we can start working on our controllers. First, we should work on our DashboardController
component so that our controllers automatically inherit some common behaviors. The steps are as follows:
Within our
DashboardController.php
component, we should first define ouraccessRules()
method. This will ensure that only administrators have access to the dashboard:public function filters() { return array( 'accessControl' ); } public function accessRules() { return array( array('allow', // allow authenticated admins to perform any action 'users'=>array('@'), ), array('deny', // deny all users 'users'=>array('*'), 'deniedCallback' => array($this, 'actionError') ), ); }
Next, we'll define the
default
layout that we'll want to use throughout the module:public $layout='default';