[eluser]Nir Gavish[/eluser]
hi all!
is there anyone who knows of an easy, elegant way for one controller to inherit (extend) another existing controller?
Thanks, Nir
[eluser]Colin Williams[/eluser]
I've still yet to come across a situation that calls for this. Most the time things can be engineered a different way. Alas, search for "HMVC" here and you'll find plenty, including a Library (or is it a hack) that turns CI's MVC to HMVC.
But, honestly, I like MVC because it's just M. V. C. and it's usually enough.
[eluser]Nir Gavish[/eluser]
Thank you for your reply.
hmvc seems like too much.
all i need is a way to declare a controller:
* class New_controller extends Old_controller
instead of:
* class New_controller extends Controller
and doing so without an ugly include OR hacking into the controller class
the reason for this is that i have a management interfce controller *that is already running* that needs to be 'delegated' to other controllers without a major rewrite.
Thanks, Nir
[eluser]Sam Dark[/eluser]
Include is not ugly in this case, I think. Else you need to write custom loaders.
[eluser]Nir Gavish[/eluser]
[quote author="Sam Dark" date="1214926833"]Include is not ugly in this case.[/quote] >> well... ok... you win, i'll use include, cheers :-) and thanks
[eluser]louis w[/eluser]
Agree, just a basic include works great for this. No sense adding extra complicated work which an include (or better yet require_once) can do.
I often create subclasses. This is a great way to create a very flexible application with minimal code duplication.
[eluser]Nir Gavish[/eluser]
[quote author="Henrik Pejer" date="1214965039"]One can easily create a MY_Controller in the application/libraries section[/quote]
Yes, but i was trying to avoid moving the controller into the library dir.
***
anyway, as far as RTFM goes, i mostly agree - however ATFF(Ask The F&%#ing Forum) works nicely as well, and you get to meet people as a bonus.
i finally used a require_once statement and extended the class, worked like a charm, i'm happy.
thanks, guys