Welcome Guest, Not a member yet? Register   Sign In
Poll: CI4: Module support?
You do not have permission to vote in this poll.
yes
88.46%
115 88.46%
no
4.62%
6 4.62%
maybe
6.92%
9 6.92%
Total 130 vote(s) 100%
* You voted for this item. [Show Results]

Module support?
#31

(06-24-2015, 09:31 PM)ivantcholakov Wrote: In pure CI3 $this within a controller context means the controller itself, $this within a view context means the loader class instance. I don't see a difficulty for understanding this concept, it is already being in use.

It's not difficult to understand at all. But WireDesignz' HMVC library does something a little different. It's not necessarily dangerous, but can be at times. The get_instance() command is built into the CI_Controller, and represents an instance of the current controller, as you said. However, when you load a second controller you now have a conflicting instance that is pointing to the second controller whenever accessing something not specifically set in that controller. To get around this, the HMVC libraries, IIRC, have an additional CI class that is used to help create a common instance that $this points to for things not within the class. And this seems to work most of the time, but can lead to some tricky debugging moments.

(06-24-2015, 09:31 PM)ivantcholakov Wrote: An additional library... No, thanks. As a rule, I don'want to write libraries with methods that return HTML output. I want to use MVC triads as visual widgets that I can simply put within the views wherever I want. Actually, it is often a designer to do these visual changes within the views only, without touching controllers, libraries or other programmer's stuff.

And that's a design choice that works for you, and that's awesome. And a decent use of MVC. What I was proposing was simply replacing the C in your triad with an L. Conceptually, they're very close, but controllers in CI have a very specific design that I think runs risks and makes things more difficult to debug on occasion. (See the Form Validation library issues that HMVC system has). Instead, the Library represents more of an Entity, I guess, than a controller, since it's not responsible for controlling the flow of data from request to response.

(06-24-2015, 09:31 PM)ivantcholakov Wrote: A reference to a talk that is close to to this one: http://forum.codeigniter.com/thread-61509.html

You're right - and I said there I liked what they did. I even implemented a simplified version of it. However, that wasn't controller calling controller. It was calling a separate class, which, in the CI world, is a library. And I don't believe their controllers have the same "global $this" issue that CI does.
Reply


Messages In This Thread
Module support? - by jlp - 04-06-2015, 05:55 PM
RE: Module support? - by gadelat - 04-06-2015, 11:20 PM
RE: Module support? - by llebkered - 04-08-2015, 08:34 AM
RE: Module support? - by Hobbes - 04-09-2015, 12:58 PM
RE: Module support? - by yurikhita - 04-09-2015, 02:21 PM
RE: Module support? - by ardhie1032 - 04-09-2015, 02:34 PM
RE: Module support? - by no1youknowz - 04-10-2015, 06:51 AM
RE: Module support? - by sintakonte - 04-12-2015, 01:52 AM
RE: Module support? - by josetrindade - 04-10-2015, 08:11 AM
RE: Module support? - by dmyers - 04-10-2015, 11:27 AM
RE: Module support? - by no1youknowz - 04-10-2015, 04:23 PM
RE: Module support? - by dmyers - 04-10-2015, 07:09 PM
RE: Module support? - by wolfgang1983 - 04-12-2015, 02:17 AM
RE: Module support? - by michalsn - 04-12-2015, 03:28 AM
RE: Module support? - by Davcon - 04-12-2015, 05:38 AM
RE: Module support? - by RWCH - 06-05-2015, 07:42 AM
RE: Module support? - by nasser.man - 06-05-2015, 08:46 AM
RE: Module support? - by nasser.man - 05-04-2015, 02:23 AM
RE: Module support? - by apsweb - 05-14-2015, 08:33 AM
RE: Module support? - by InsiteFX - 06-06-2015, 11:13 PM
RE: Module support? - by ivantcholakov - 06-07-2015, 07:49 AM
RE: Module support? - by nasser.man - 06-13-2015, 01:31 AM
RE: Module support? - by PaulD - 06-22-2015, 07:22 PM
RE: Module support? - by no1youknowz - 06-23-2015, 08:34 PM
RE: Module support? - by ivantcholakov - 06-22-2015, 11:30 PM
RE: Module support? - by sintakonte - 06-24-2015, 07:51 AM
RE: Module support? - by ivantcholakov - 06-24-2015, 08:21 AM
RE: Module support? - by sintakonte - 06-24-2015, 08:38 AM
RE: Module support? - by kilishan - 06-24-2015, 07:52 PM
RE: Module support? - by sintakonte - 06-25-2015, 01:11 AM
RE: Module support? - by ivantcholakov - 06-24-2015, 09:31 PM
RE: Module support? - by kilishan - 06-24-2015, 09:56 PM
RE: Module support? - by ivantcholakov - 06-24-2015, 10:18 PM
RE: Module support? - by nc03061981 - 06-25-2015, 09:21 AM
RE: Module support? - by dmyers - 06-26-2015, 04:52 AM
RE: Module support? - by ivantcholakov - 06-26-2015, 10:32 AM
RE: Module support? - by dmyers - 06-26-2015, 02:52 PM
RE: Module support? - by RWCH - 06-30-2015, 03:11 PM
RE: Module support? - by ivantcholakov - 07-02-2015, 04:42 AM
RE: Module support? - by solidcodes - 09-23-2015, 02:16 AM
RE: Module support? - by InsiteFX - 09-23-2015, 04:13 AM
RE: Module support? - by Narf - 09-23-2015, 05:05 AM
RE: Module support? - by Martin7483 - 09-24-2015, 02:11 AM
RE: Module support? - by mwhitney - 09-24-2015, 07:16 AM
RE: Module support? - by solidcodes - 09-24-2015, 03:53 AM
RE: Module support? - by mwhitney - 09-24-2015, 11:12 AM
RE: Module support? - by Narf - 09-25-2015, 01:50 AM
RE: Module support? - by Martin7483 - 09-25-2015, 02:43 AM
RE: Module support? - by mwhitney - 09-25-2015, 08:55 AM
RE: Module support? - by Martin7483 - 09-25-2015, 09:17 AM
RE: Module support? - by mwhitney - 09-25-2015, 11:18 AM
RE: Module support? - by Martin7483 - 09-26-2015, 04:59 AM
RE: Module support? - by Ivo Miranda - 06-26-2016, 05:14 PM
RE: Module support? - by kilishan - 06-26-2016, 07:52 PM
RE: Module support? - by orionstar - 06-26-2016, 09:54 PM
RE: Module support? - by Ivo Miranda - 06-27-2016, 04:58 AM
RE: Module support? - by ivantcholakov - 09-20-2016, 08:49 AM
RE: Module support? - by Narf - 09-20-2016, 10:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB