require_once (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library') . '/Zend/Loader/AutoloaderFactory.php';
Zend\Loader\AutoloaderFactory::factory();
-if (!($env = getenv('APPLICATION_ENV'))) {
- $env = 'local';
-}
-
$appConfig = include 'config/application.config.php';
+$sharedEvents = new Zend\EventManager\SharedEventManager();
$listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']);
$defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions);
-$defaultListeners->getConfigListener()->addConfigGlobPath("config/autoload/*.{global,$env}..configphp");
+$defaultListeners->getConfigListener()->addConfigGlobPath("config/autoload/*.php");
+
$moduleManager = new Zend\Module\Manager($appConfig['modules']);
-$moduleManager->events()->attachAggregate($defaultListeners);
+$events = $moduleManager->events();
+$events->setSharedCollections($sharedEvents);
+$events->attach($defaultListeners);
$moduleManager->loadModules();
// Create application, bootstrap, and run
$bootstrap = new Zend\Mvc\Bootstrap($defaultListeners->getConfigListener()->getMergedConfig());
+$bootstrap->events()->setSharedCollections($sharedEvents);
$application = new Zend\Mvc\Application;
$bootstrap->bootstrap($application);
$application->run()->send();