Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

ModuleManager load module childs dependentsLoad childs modules #50

Closed
wants to merge 1 commit into from
Closed

ModuleManager load module childs dependentsLoad childs modules #50

wants to merge 1 commit into from

Conversation

turrsis
Copy link

@turrsis turrsis commented Oct 31, 2016

Allow load modules (from Module::init()) after current module.
Analog of zendframework/zendframework#5651, but:
load modules A, B - configs order is A, B.
load modules A -> B - configs order is A, B.

recreated from #47

$this->loadFinished = 0;
if ($this->loadFinished > 0 && $this->parentModule && $afterCurrent) {
$childModule = is_object($module)
? array($moduleName=>$module)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short array syntax

Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks interesting, but I'm uncertain how it should be used. As such:

  • Please rebase against current develop branch. In particular, how you test against events has changed to ensure you can test against both zend-servicemanager v2 and v3.
  • Please provide usage documentation: how do you declare a child module? what happens when a child module has its own dependencies? and so on.
  • What happens if a child module is also declared in the module list?

Essentially, some documentation needs to be done, as well as a number of code changes, before we can accept this.

*
* @var array
*/
protected $childsModules = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use $childModules throughout ("childs" is not grammatically correct).

$this->loadFinished = 0;
if ($this->loadFinished > 0 && $this->parentModule && $afterCurrent) {
$childModule = is_object($module)
? [$moduleName=>$module]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run this against phpcs; we require spaces around all operators.

* @param ModuleEvent $e
* @return void
*/
public function onLoadChildsModules(ModuleEvent $e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed to onLoadChildModules.

@@ -62,6 +62,7 @@ public function testDefaultListenerAggregateCanAttachItself()
'Zend\ModuleManager\Listener\OnBootstrapListener',
'Zend\ModuleManager\Listener\ConfigListener',
'Zend\ModuleManager\Listener\LocatorRegistrationListener',
'Zend\ModuleManager\ModuleManager',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this already be registered (due to registration of the onLoadModules listener)? Why is this change necessary?

@@ -140,7 +170,7 @@ public function loadModules()
* @triggers loadModule
* @return mixed Module's Module class
*/
public function loadModule($module)
public function loadModule($module, $afterCurrent = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the new $afterCurrent argument, please. What are valid values?

public function init($moduleManager)
{
$moduleManager->loadModule('LoadChildsModule2', 'after');
$moduleManager->loadModule(['SomeModule' => new \SomeModule\Module()], 'after');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the second argument be a boolean true? While non-empty strings evaluate as truthy, using them for boolean conditionals is brittle.

@weierophinney
Copy link
Member

Closing due to inactivity and lack of response by author to feedback and questions raised.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants