• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where to put plain object classes?

#45
(01-06-2015, 05:18 AM)Jamie Wrote: I may have misunderstood your question here - apologies if this is the case, but take a look at Loader Class Documentation about passing parameters to models.

Edit: Just noticed that this had already been suggested by includebeer here.

That applies to the loading of libraries only and you are limited to just one parameter. Unless I am missing something, you cannot supply any parameters at all when loading a model. Also, I find it curious that CI doesn't use call_user_func_array for loading libraries so that one can specify multiple parameters to a library constructor that accepts multiple parameters.

I fully recognize that CI is designed the way it is and that one must get used to certain peculiarities with any framework. One of the nice things about CI as I've seen it is that it seems pretty flexible in that it doesn't force you into any particular coding mode unnecessarily. As for the question "Where to put plain object classes?" I think the following are pretty important information when deciding where to put one's classes:
1) If you use CI's loader to load your libraries, they must be designed such that their constructor accepts at most one parameter
2) If you use CI's loader to load your models, their constructors must expect no parameters
3) If you use CI's loader to load your libraries or models, they are going to be automatically instantiated
4) If you plan to extend CI_Model, you must either load some model using the loader or you must explicitly include/require the CI_Model class which is found in system/core/Model.php
Reply


Messages In This Thread
Where to put plain object classes? - by geekita - 12-02-2014, 05:51 AM
RE: Where to put plain object classes? - by Jamie - 01-06-2015, 05:18 AM
RE: Where to put plain object classes? - by sneakyimp - 01-06-2015, 01:04 PM
RE: Where to put plain object classes? - by Jamie - 01-06-2015, 03:08 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.