[Tutorial] Maintenance Of Each Controller

I had read an article about maintenance in Yii:


http://www.yiiframework.com/forum/index.php/topic/3975-maintenance-mode/

it’s very nice, but the problem here is, I want SiteController still works but NewsController (PollController, …) is maintenance, so how?

This my way, very simple. In file config/main.php:


'params'=>array(

    ....

    'maintenance' => array(

        // configure controller maintenance you want. True is maintenance, not exists or False is not maintenance

	'news' => true 

    )

)

Now, in file components/Controller.php


class Controller extends CController

{

   public function init()

   {

      $controllerID = Yii::app()->controller->id;


      if (isset(Yii::app()->params['maintenance'][$controllerID]) 

          && Yii::app()->params['maintenance'][$controllerID] == true) {

          //your code for maintenance

          Yii::app()->end();

      }

   }

}

This my way, hope can help you, tks for read my topic