Welcome Guest, Not a member yet? Register   Sign In
Extending Model class
#6

[eluser]Mirage[/eluser]
Models are not supported for core class extension.

What's more, Models need to be in the 'models' directory if you want to load them [in your controller] using the Loader class. Those are the reasons you have to include it yourself. - which I don't find to be all that awful anyway.

If you want your CMS_Model to 'just be there' right from the start on every framework load, you have a couple of options:

1. Leave your model class file in the libraries folder and add it to the autoloader config.

2. The potential problem with #1 is that the autoloaded libraries are automatically instantiaded in the controller. Might not be an issue for you, but perhaps you don't like that. I certainly don't. So the option is to make it a helper or plugin and put it in those respective folders. There are no rules that say you can't have class definitions in helpers or plugins. So this will include the file, but not instantiate it.

3. #2 is a bit hacky as well. So why I did is to write a 'classloader' plugin, which I auto load. In that plugin I write include statements for all the class libs I need to load without instantiating them.

4. Instead of autoloading a plugin like I suggest in #3, you can write it as a pre-controller hook. I think that's probably most 'correct' way of handling this.

HTH


Messages In This Thread
Extending Model class - by El Forum - 07-09-2007, 06:18 AM
Extending Model class - by El Forum - 07-09-2007, 06:49 AM
Extending Model class - by El Forum - 07-10-2007, 01:54 AM
Extending Model class - by El Forum - 07-10-2007, 02:17 AM
Extending Model class - by El Forum - 07-10-2007, 03:19 AM
Extending Model class - by El Forum - 07-10-2007, 11:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB