开发者

Need help with understand AppController class in CakePHP

开发者 https://www.devze.com 2023-03-01 02:07 出处:网络
I passed through few basic tutorials of CakePHP. Now I\'m trying to understand Authentication Component.

I passed through few basic tutorials of CakePHP. Now I'm trying to understand Authentication Component.

Why in this tutorial: http://book.cakephp.org/pl/view开发者_运维百科/643/Preparing-to-Add-Auth they create new class AppController? I ask because I've just created some controllers where classes inherited from AppController class and I haven't had the own AppController class yet.


You create a new AppController to define new extended functionality for your controllers.

Basically all your controllers should extend your new AppController class, which defines all your authentication logic. These beforeFilter()/afterFilter() methods are run automatically by your dispatcher and these methods can dictate whether or not to continue processing the current controller.


Next we need to make some modifications to AppController. If you don't have /app/app_controller.php, create it. Note that this goes in /app/, not /app/controllers/. Since we want our entire site controlled with Auth and Acl, we will set them up in AppController.

In this example, you are simply making modifications (adding a beforeFilter() callback) to the "skeleton" AppController class. This class will be extended by all of the controllers in your app. It's a way to add functionality that applies to all controllers in your app.

0

精彩评论

暂无评论...
验证码 换一张
取 消