Reputation: 1399
I don't know if this is a duplicate, I couldn't find anything. I'm sorry.
Alright, so I've made a couple of classes like this:
abstract class Bank(){}
class HB extends Bank(){}
class NO extends Bank(){}
class BankController(){}
class Contract(){}
and I'm using them like this:
$contract = new Contract();
$bank = new HB();
$bankC = new BankController($bank);
$bankC->setContract($contract)->processContract()->sendRequest();
My question is, where do I put the BankController? Because I don't really wanna put them in the controller folder cause I don't want to access them through the URL. What would you guys do? Or do you create a new folder?
Upvotes: 0
Views: 2438
Reputation: 4527
You could create a Custom core controller:
http://ellislab.com/codeigniter/user-guide/general/core_classes.html
OR you could create a library if you would not want it on the url:
http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
on the application/libraries directory create a
bank.php
or you could create a folder like bankfolder/bank.php
class bank()
{
public function setContract()
{
//
}
public function processContract()
{
//
}
public function sendRequest()
{
//
}
}
then on HB COntroller
class HB extends CI_Controller
{
public function __construct(){
parent::__construct();
$this->load->library('bankfolder/bank');
}
public function index()
{
$this->bank->setContract($contract)->processContract()->sendRequest();
}
}
This is just a sample and not a working code of yours
Upvotes: 1
Reputation: 189
You can make a controller function private by starting the name with a underscore. So for example Contract would be accesible if you placed it in the controller folder but _Contract would not. You will still be able to use it within your controller file itself if you might need that one day.
Upvotes: 1