开发者

Kohana 3 Extending Module Model File Structure

I have some code that is used both by the admin and public models. Currently some of the methods are exactly the same, but stored in the separate models of the admin and public sections. I created a module called common and I want to store shared pieces of code there by having the admin and public models extend from the common model. I'm just confused on the structure to set it up. Assuming I have:

Model_Post extends Model
Model_Admin_Post extends Model

Should the structure be like:

modules/common/classes/model/common/post.php
Model_Post extends Model_Common_Post

or

modules/common/classes/common/model/post.php
Model_Post extends Common_Model_Post

or

modules/common/classes/model/post/common.php
Model_Post extends Model_Post_Common

I've tooken a look at a few modules and it seems to vary, so is it really just up to how you feel like structuring it? I noticed the auth module, which is an official module seems to follow the firs开发者_如何学Ct example, but I'm not too sure. Although it seems easier to use the 2nd or 3rd way as you just tack on the module name to the beginning or end instead. In the long run I think it'd be better to follow the "correct" way for consistency. Which of these would be correct, if at all?


// modules/common/classes/model/common/post.php
Model_Common_Post extends Model {}

// ADMIN/application/classes/model/admin/post.php
Model_Admin_Post extends Model_Common_Post {}

// PUBLIC/application/classes/model/post.php
Model_Post extends Model_Common_Post {}

So, your public and admin models should be placed in their applications dirs, and common files (common_post model) is in common module.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜