如何将我的业务逻辑与Codeigniter中的控制器分开。我正在使用HMVC和Phills模板库。这是我目前的设置。
//应用程序/核心/ MY_controller.php
class My_controller extends MX_controller
{
function __construct()
{
parent::__construct();
}
}
class dCommerce extends MY_controller
{
function __construct()
{
parent::__construct();
#Some of my code that shares the entire app, ex: login
}
}
现在在控制器中我想要这样的东西 //Application/controllers/sales_order.php
class Sales_order extends dCommerce extends dSales_Order
{
//dSales_Order have all my core APP logic
}
我知道PHP无法实现多重继承,但是如何将逻辑与控制器分开?
Sales_order
将包含我所有基于框架的逻辑(依赖app)ex,验证和核心类dSales_Order
将具有核心app逻辑ex。保存,创建等
样本会是这样的......
class dSales_Order
{
function save( $sales_order_id , $details )
{
//blah blah codes and APP logic, too much of math
//and then save to DB, this class will be framework Independed
//only pure php code
}
}
我怎样才能实现这个目标?
答案 0 :(得分:1)
答案 1 :(得分:0)
好的,我想我明白你从哪里来的;在交换了一些评论后。
以下是我认为你应该做的事情:
希望这有帮助。