CodeIgniter Forums
Extending abstract classes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Extending abstract classes (/showthread.php?tid=55535)



Extending abstract classes - El Forum - 10-31-2012

[eluser]Unknown[/eluser]
Hey,

I'm currently working on a PHP game engine and I would like to make my object modelisation fit into Codeigniter.

I first started to work with models, but I can only extend my classes from CI_Model or MY_Model. It could be a solution, but I can't extend an already-extended class.

Then, I worked my libraries, but I have another problem :
My Unit class extends from the GenericObject abstract class.
If I don't add the GenericObject class to the $autoload['libraries'] array, I can't instance any Unit object.
If I add the GenericObject class to the $autoload['libraries'] array, then CI tries to instances a GenericObject object and causes a PHP error because you can't instance an abstract class.

Is there any way to let CI know about classes without instancing them ?


Extending abstract classes - El Forum - 10-31-2012

[eluser]WanWizard[/eluser]
I'm afraid CI's architecture doesn't suit modern designs very well.

Throw in a class autoloader and you can do anything you want. You can find plenty of references to this on the web, for example this one: http://ajmm.org/2011/06/include-codeigniter-models-using-spl_autoload/


Extending abstract classes - El Forum - 10-31-2012

[eluser]solid9[/eluser]
@WanWizard
If that is the case do the CI Core dev team has a plan to suite CI into modern designs
with PHP latest version?