zendframework/zf2 — pull request #597 by EvanDotPro (2011-11-13 23:24:42+00:00)
Title: Module manager refactored to be more event driven

## NOTE: There are a couple of minor BC breaks in this PR.

### Included in this PR:

- Module manager now simply calls a loadModule event for each loaded module.
- Various behavior such as calling init(), merging config, and registering autoloaders has been moved off into specific listeners.
- A couple of minor BC breaks (see below).
- All unit tests have been updated, 100% code coverage.

### BC Breaks:

- Zend\Module\ManagerOptions has been removed.
- You must now call $moduleManager->loadModules() explicitly in index.php.
- Merged config object is now passed to bootstrap instead of the module manager.

In your `public/index.php`, where you used to have:

$moduleManager = new Zend\Module\Manager(
$appConfig['modules'],
new Zend\Module\ManagerOptions($appConfig['module_manager_options'])
);
$bootstrap = new Zend\Mvc\Bootstrap($moduleManager);

You will now have this:

$moduleManager = new Zend\Module\Manager($appConfig['modules']);
$moduleManager->loadModules();
$bootstrap = new Zend\Mvc\Bootstrap($moduleManager->getMergedConfig());

Or more explicitly:

$moduleManager = new Zend\Module\Manager($appConfig['modules']);
$listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_manager_options']);
$moduleManager->setDefaultListenerOptions($listenerOptions);
$moduleManager->loadModules();
$bootstrap = new Zend\Mvc\Bootstrap($moduleManager->getMergedConfig());

If in any of your module's `Module` class you are making use of the 'bootstrap' check if you are using:

$config = $e->getParam('modules')->getMergedConfig();

If so, change it to this:

$config = $e->getParam('config');

That should be about it for BC breaks.