在Controller_Base
所有其他控制器中扩展自。例如
文件 application/classes/Controller/Base.php
class Controller_Base extends Controller_Template {
public function before()
{
$isClose = DB::query(.....)
if($isClose)
{
HTTP::redirect("http://mypage.com/website_is_close");
exit ;
}
parent::before();
}
}
所有其他类都应该从该类扩展,例如
class Controller_Home extends Controller_Base {}
我个人也将它用于每个子目录,例如
// As all controllers in the user folder probably need to be supplied with a user anyway
class Controller_User_Base extends Controller_Base {}
class Controller_User_Profile extends Controller_User_Base {}