How can i separate my business logic away from my controllers in Codeigniter. I am using HMVC with Phills template library. Here is my current setup.
//Application/core/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
}
}
Now in controller i want something like this //Application/controllers/sales_order.php
class Sales_order extends dCommerce extends dSales_Order
{
//dSales_Order have all my core APP logic
}
i know that multiple inheritance is not possible with PHP, However how can i separate the logic from controllers ?
Sales_order
will contain all my framework based logic (depends app) ex, validation and the core class dSales_Order
will have the core app logic ex. Save,Create etc
A sample would be like this ...
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
}
}
How can i achieve this ?
I am sorry for my bad English.
I hope your doubts is an OOPS and PHP related. I cannot understand your full requirements.
Even I recommend you to go with new PHP concept called
traits
or interfaces in PHP