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

Improve module manager to accept instance #3814

Closed
wants to merge 3 commits into from
Closed

Improve module manager to accept instance #3814

wants to merge 3 commits into from

Conversation

blanchonvincent
Copy link
Contributor

Hi,

For the performance and to make learning easier, we can accept modules instances :

Before :

<?php
return array(
    'modules' => array(
        'Application',
        'Cron',
        'Administration',
        'Blog',
    ),
    'module_paths' => array(// my paths),
);
?>

Now, i do :

<?php
return array(
    'modules' => array(
        'Application' => new Application\Module(),
        'Cron' => new Cron\Module(),
        'Administration' => new Administration\Module(),
        'Blog' => new Blog\Module(),
    ),
);
?>

There is no BC, more natural, and perf little better.

@ghost ghost assigned EvanDotPro Feb 19, 2013
@ralphschindler
Copy link
Member

I like the explicitness, but how does your PHP know where these objects are located on disk? The inclusion of this particular application.ini file is before any kind of autoload munging. This would seem to imply that module/ is in your include_path and you have a special autoloader for it?

@blanchonvincent
Copy link
Contributor Author

@ralphschindler if i use init_autoloader.php like the skeleton (with an autoloader : classmap autoloader, standard autoloader, etc.), there is no problems

{
$moduleName = $module;
if(is_object($module)) {
Copy link
Member

Choose a reason for hiding this comment

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

Add space between statement and conditional.

@weierophinney
Copy link
Member

As noted above, I think a few additional tests and use cases need to be considered.

@blanchonvincent
Copy link
Contributor Author

@weierophinney I updated the PR (test with type & submodule) Do you think in other use cases ?

$event = ($this->loadFinished === false) ? clone $this->getEvent() : $this->getEvent();
$event->setModuleName($moduleName);

if (!is_object($module)) {
Copy link
Member

Choose a reason for hiding this comment

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

To keep this method clean (and small), perhaps you could move the contents of this if-block to their own method (e.g. loadModuleByName())?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok look cool, I updated my PR

@Freeaqingme
Copy link
Member

I like the PR from a functional perspective. I'll let it to @weierophinney or @EvanDotPro to do the final review however.

Please note, as it primarily introduces new functionality, I think it should be merged into develop only(?).

weierophinney added a commit that referenced this pull request Mar 11, 2013
- trailing whitespace
weierophinney added a commit that referenced this pull request Mar 11, 2013
@weierophinney
Copy link
Member

Merged to develop for release with 2.2.0.

weierophinney added a commit to zendframework/zend-modulemanager that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-modulemanager that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants