[eluser]blasto333[/eluser]
Is it necessary to have all Controllers that override Controller in application/libraries/MY_Controller.php?
I know this way they will be autoloaded, but what is the harm in doing this:
Currently in MY_Controller I have this:
class Secure_Area extends Controller
{
..
..
..
}
abstract class Person_Controller extends Secure_Area implements iPerson_Controller
{
..
..
..
}
For readability I would rather have two separate files:
libraries/Secure_Area.php
libraries/Person_Controller.php
[eluser]blasto333[/eluser]
I just ended up making separate files and then doing a require_once inside MY_Controller.php
[eluser]Frank Berger[/eluser]
ok, makes more sense now. I had/have the same problem with the phpgACL implementation i posted in the forum here as well. The problem is that the autoload comes too late.
You're right in this case a my_controller with an include is my 'cheap' alternative as well. The only other option you have is to look into the hook functionality. There you can execute commands very early in CI's life-cycle, and within such a function you can include a custom controller class as well (or more than one)
hope that helps
Frank
[eluser]Rick Jolly[/eluser]
In the name of transparency, I just require/include parent classes in the child class. It's self documenting. I don't use MY_Controller because, as you wrote, if you want more than one parent controller, you have to hide them away in the same file. Alternatively, if using class naming conventions, you could write a simple php 5 __autoload() function.
[eluser]blasto333[/eluser]
Thats what I ended up doing, but didn't use __autoload as I think being verbose and transparent makes it a lot easier to understand. (Just like you said)
[quote author="Rick Jolly" date="1224452562"]In the name of transparency, I just require/include parent classes in the child class. It's self documenting. I don't use MY_Controller because, as you wrote, if you want more than one parent controller, you have to hide them away in the same file. Alternatively, if using class naming conventions, you could write a simple php 5 __autoload() function.[/quote]