-
Book Overview & Buying
-
Table Of Contents
Yii Application Development Cookbook - Second Edition - Second Edition
In many frameworks, the concept of a base controller that is being extended by other ones is described right in the guide. In Yii, it is not in the guide as you can achieve flexibility in many other ways. Still, using a base controller is possible and can be useful.
We are going to set up a new application using yiic webapp.
Let's say we want to add some controllers that will be accessible only when the user is logged in. We can surely set this constraint for each controller separately, but we will do it in a better way.
First, we will need a base controller that our user-only controllers will use. Let's create SecureController.php in the protected/components directory with the following code:
<?php
class SecureController extends Controller
{
public function filters()
{
return array(
'accessControl',
);
}
public function accessRules()
{
return array(
array('allow',
...
Change the font size
Change margin width
Change background colour