Codeigniter Class Inheritance between modules (wiredesigns)

时光毁灭记忆、已成空白 提交于 2019-12-23 02:43:43

问题


My CI2 app is using the wiredesigns modular layout.

I have a two modules called item and product in a a folder called modules like so:

/application
    /modules
        /item
        /product

In Item I have a controller called item which starts like this.

class Item extends MX_Controller
{
    //code here
}

What do I need to do to make my products controller extend my item controller in a different module


回答1:


My guess is you are trying to keep your code "DRY" (http://en.wikipedia.org/wiki/Don't_repeat_yourself) which in CI means using a common controller like a My_Controller (see: http://ellislab.com/codeigniter/user-guide/general/core_classes.html).

Check out Phil Sturgeon's take: http://philsturgeon.co.uk/blog/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY.



来源:https://stackoverflow.com/questions/13994457/codeigniter-class-inheritance-between-modules-wiredesigns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!