-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Allow modules to load their own dependencies #5651
Conversation
test whether a module can load a module that was not in the initial list of modules to be loaded
@@ -34,11 +34,6 @@ class ModuleManager implements ModuleManagerInterface | |||
protected $event; | |||
|
|||
/** | |||
* @var bool | |||
*/ | |||
protected $loadFinished; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BC break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, reverted.
remove unnecessary loadFinished boolean
previously the loadFinished prop was only used in binary form (true/false). change to integer (0..) so as to keep track of nested loadModule() calls.
- wait until zendframework/zendframework#5651 is accepted
Thanks! I really can't think of any reason not to merge this. It's something I semi-planned on supporting in the ModuleManager anyway, but never polished (ModuleEvent object reference being the primary issue). I'm going to sleep on it just to make sure it won't break anything else I haven't thought of. |
Yes, that should be fine. The As a bonus this also handles circular dependencies very nicely. Only caveat is you cannot use |
Yeah, I don't even know how the module dependency thing slipped in there. We had something like this in an early beta, but I explicitly removed it because it made no sense at all during runtime. I don't see an incompatibility with getModuleDependencies() as a blocker for this. |
My concern with this approach is that it will, if used, override module loading order, which can be very important during configuration merging. |
@Xerkus whoever wants to use a module that makes use of this feature and does NOT want the automatic initialization of dependency modules can just subclass and re-define the |
👍 |
My only question at this time is: can we have some more robust tests to ensure that we don't get into an infinite loop situation, please? |
Allow modules to load their own dependencies
- Moved new test assertions into their own test case to ensure they failed before the patch was made.
After discussion in IRC with @EvanDotPro, merged to develop for release in 2.3.0. Separated new assertions into their own test case to validate that the behavior did not work prior to the change. |
Note: Because deps loading will now live inside module's php code (as opposed to config file) it will be harder to automate deployment/installation. There is no simple way to "retrieve module's dependencies" and the only effect of a misconfiguration or missing modules is an error being thrown. That's bad for stuff like ZFTool or any form of module installation automation. |
@Thinkscape could you give me an example for your situation? I haven't used the dependency checker ever and I'm not exactly sure of the specifics of the use-case. I could submit a patch to |
When i load |
@turrsis This is ok. |
What if two modules try to load each other? |
@thestanislav you'd get a maximung nesting level error AFAIK. You can write a test for it. |
@thestanislav That's what #5948 tests for. It won't result in an error. |
…re/sub-module Allow modules to load their own dependencies
- Moved new test assertions into their own test case to ensure they failed before the patch was made.
…ing, and circular deps
Just testing the waters here.
Let's say our application has 3 modules A, B, and C. Module B depends on modules C, D, and E.
But in our
application.config.php
we only specify A, B, and C.This little patch will allow B to load its dependencies D and E without having the user to specify it in their
application.config.php
.