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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Promote develop to master, becoming the next stable release.
  • Loading branch information
weierophinney committed Mar 12, 2014
162 parents 786619f + 9fb11da + c2e87c3 + 62f83fa + cec8933 + d240b5c + 940c8ec + 3f85108 + 2e38381 + 027f505 + 5a2ba91 + 823b2d4 + 05c2a86 + fe05cd7 + 1009849 + e109317 + 4dff7e8 + ce0c75d + 6a82230 + 215e77c + 7e16a91 + 2493ed4 + 7ab2816 + 3d2db08 + 6fea908 + aad063e + 06319a5 + aee1ae3 + 412f870 + 9b0f1d4 + e8236b3 + 3e482af + 84d85f9 + 2edbf66 + 7b83fea + ae75c15 + 56429a2 + 3463608 + a990d75 + ed0260a + 40ce9ee + 540e95d + a1f3efa + b138336 + 0ac8011 + 498f096 + a002c09 + a72d069 + d696070 + 95b016c + f72f2a8 + 63f9aa4 + c62eb22 + 56ff1e4 + 17753e6 + 261ddba + 9c23ce8 + d2ea716 + 8a38d20 + 29c3c53 + 9681f39 + 7dc76e1 + 7e1a689 + f52efc3 + 5400ef9 + 2de31e5 + 5ef1929 + 5d57927 + fb86f9e + a0d3c0d + 754d50b + 9ae8ef7 + 80bb476 + 7a4072e + 1b4e215 + 9e453d7 + 1f0f6c3 + 512d4f8 + 702eefc + 1f67b00 + 7233001 + 4244857 + 163015b + fd694bc + a17a889 + 6aea729 + 1946426 + 0177483 + 27a94da + 8afdcae + 8e4ac91 + d060a98 + 725a039 + 4dc194c + 246b9e4 + 5207d60 + dbe0e62 + 429b268 + d48dc13 + afcf71c + 64397cc + 48ea5ac + b4afa2a + 11643c5 + cd431ca + 51b7c50 + 82247be + d2994aa + eaf4e29 + eeb69a6 + 3e3fff3 + c0a95c9 + 961798f + 57ae4ec + a4fa631 + 259684b + b38977d + 1a640d1 + e064a96 + 3913f14 + fe5e75d + 3085bbe + 8e7f807 + 09e57f8 + fd510c1 + 80c8682 + fc0c293 + 497c115 + 49df818 + d645847 + ee12220 + 9b92152 + 9059103 + a7a5529 + be06b37 + 590c66e + df27e78 + 1e31131 + adb430e + 1c9aa26 + 7abe866 + dfe045d + 1b4822b + ae1f9f3 + 986e6d4 + 6424a7a + 25f7da3 + 24a8854 + 626d785 + d87a2f0 + 27c896d + 350b8cf + 6bab62b + 1822787 + 0b5ec15 + 8abed0c + 2090aa6 + 883b5fd + 4f3d0a9 + 908dbe4 + 2bd3583 + ecb5aa8 commit 3b54f16
Show file tree
Hide file tree
Showing 36 changed files with 146 additions and 49 deletions.
19 changes: 13 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@
}
},
"require": {
"php": ">=5.3.3",
"php": ">=5.3.23",
"zendframework/zend-eventmanager": "self.version",
"zendframework/zend-stdlib": "self.version"
},
"require-dev": {
"zendframework/zend-config": "self.version",
"zendframework/zend-console": "self.version",
"zendframework/zend-loader": "self.version",
"zendframework/zend-mvc": "self.version",
"zendframework/zend-servicemanager": "self.version",
"fabpot/php-cs-fixer": "1.7.*",
"satooshi/php-coveralls": "dev-master",
"phpunit/PHPUnit": "~4.0"
},
"suggest": {
"zendframework/zend-config": "Zend\\Config component",
"zendframework/zend-console": "Zend\\Console component",
"zendframework/zend-loader": "Zend\\Loader component",
"zendframework/zend-mvc": "Zend\\Mvc component",
"zendframework/zend-servicemanager": "Zend\\ServiceManager component"
},
"extra": {
Expand All @@ -32,10 +44,5 @@
"psr-4": {
"ZendTest\\ModuleManager\\": "test/"
}
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"satooshi/php-coveralls": "dev-master",
"phpunit/PHPUnit": "~4.0"
}
}
21 changes: 21 additions & 0 deletions src/Feature/LogProcessorProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\ModuleManager\Feature;

interface LogProcessorProviderInterface
{
/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
*
* @return array|\Zend\ServiceManager\Config
*/
public function getLogProcessorConfig();
}
21 changes: 21 additions & 0 deletions src/Feature/LogWriterProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\ModuleManager\Feature;

interface LogWriterProviderInterface
{
/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
*
* @return array|\Zend\ServiceManager\Config
*/
public function getLogWriterConfig();
}
24 changes: 21 additions & 3 deletions src/Listener/ConfigListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public function attach(EventManagerInterface $events)
}

$this->callbacks[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE, array($this, 'onLoadModule'));
$this->callbacks[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULES, array($this, 'onLoadModulesPost'), -1000);

$this->callbacks[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULES, array($this, 'onLoadModules'), -1000);
$this->callbacks[] = $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'onMergeConfig'), 1000);
return $this;
}

Expand Down Expand Up @@ -137,7 +137,7 @@ public function onLoadModule(ModuleEvent $e)
* @param ModuleEvent $e
* @return ConfigListener
*/
public function onLoadModulesPost(ModuleEvent $e)
public function onMergeConfig(ModuleEvent $e)
{
// Load the config files
foreach ($this->paths as $path) {
Expand All @@ -150,6 +150,24 @@ public function onLoadModulesPost(ModuleEvent $e)
$this->mergedConfig = ArrayUtils::merge($this->mergedConfig, $config);
}

return $this;
}

/**
* Optionally cache merged config
*
* This is only attached if config is not cached.
*
* @param ModuleEvent $e
* @return ConfigListener
*/
public function onLoadModules(ModuleEvent $e)
{

// Trigger MERGE_CONFIG event. This is a hook to allow the merged application config to be
// modified before it is cached (In particular, allows the removal of config keys)
$e->getTarget()->getEventManager()->trigger(ModuleEvent::EVENT_MERGE_CONFIG, $e->getTarget(), $e);

// If enabled, update the config cache
if (
$this->getOptions()->getConfigCacheEnabled()
Expand Down
10 changes: 5 additions & 5 deletions src/ModuleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class ModuleEvent extends Event
/**
* Module events triggered by eventmanager
*/
CONST EVENT_MERGE_CONFIG = 'mergeConfig';
CONST EVENT_LOAD_MODULES = 'loadModules';
CONST EVENT_LOAD_MODULE_RESOLVE = 'loadModule.resolve';
CONST EVENT_LOAD_MODULE = 'loadModule';
CONST EVENT_LOAD_MODULES_POST = 'loadModules.post';
const EVENT_MERGE_CONFIG = 'mergeConfig';
const EVENT_LOAD_MODULES = 'loadModules';
const EVENT_LOAD_MODULE_RESOLVE = 'loadModule.resolve';
const EVENT_LOAD_MODULE = 'loadModule';
const EVENT_LOAD_MODULES_POST = 'loadModules.post';

/**
* @var mixed
Expand Down
20 changes: 17 additions & 3 deletions src/ModuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,24 @@ public function loadModule($module)
return $this->loadedModules[$moduleName];
}

$event = ($this->loadFinished === false) ? clone $this->getEvent() : $this->getEvent();
/*
* Keep track of nested module loading using the $loadFinished
* property.
*
* Increment the value for each loadModule() call and then decrement
* once the loading process is complete.
*
* To load a module, we clone the event if we are inside a nested
* loadModule() call, and use the original event otherwise.
*/
if (!isset($this->loadFinished)) {
$this->loadFinished = 0;
}

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

$this->loadFinished = false;
$this->loadFinished++;

if (!is_object($module)) {
$module = $this->loadModuleByName($event);
Expand All @@ -153,7 +167,7 @@ public function loadModule($module)
$this->loadedModules[$moduleName] = $module;
$this->getEventManager()->trigger(ModuleEvent::EVENT_LOAD_MODULE, $this, $event);

$this->loadFinished = true;
$this->loadFinished--;

return $module;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Listener/AutoloaderListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
4 changes: 2 additions & 2 deletions test/Listener/ConfigListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down Expand Up @@ -378,7 +378,7 @@ public function testConfigListenerFunctionsAsAggregateListener()
$this->assertEquals(2, count($moduleManager->getEventManager()->getEvents()));

$configListener->attach($moduleManager->getEventManager());
$this->assertEquals(3, count($moduleManager->getEventManager()->getEvents()));
$this->assertEquals(4, count($moduleManager->getEventManager()->getEvents()));

$configListener->detach($moduleManager->getEventManager());
$this->assertEquals(2, count($moduleManager->getEventManager()->getEvents()));
Expand Down
4 changes: 2 additions & 2 deletions test/Listener/DefaultListenerAggregateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down Expand Up @@ -108,7 +108,7 @@ public function testDefaultListenerAggregateCanDetachItself()
$this->assertEquals(1, count($moduleManager->getEventManager()->getEvents()));

$listenerAggregate->attach($moduleManager->getEventManager());
$this->assertEquals(3, count($moduleManager->getEventManager()->getEvents()));
$this->assertEquals(4, count($moduleManager->getEventManager()->getEvents()));

$listenerAggregate->detach($moduleManager->getEventManager());
$this->assertEquals(1, count($moduleManager->getEventManager()->getEvents()));
Expand Down
2 changes: 1 addition & 1 deletion test/Listener/InitTriggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/ListenerOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/LocatorRegistrationListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/ModuleDependencyCheckerListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/ModuleLoaderListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/ModuleResolverListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/OnBootstrapListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/ServiceListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/TestAsset/ServiceInvalidReturnModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/Listener/TestAsset/ServiceProviderModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/ModuleEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
17 changes: 16 additions & 1 deletion test/ModuleManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down Expand Up @@ -146,6 +146,21 @@ public function testCanLoadModuleDuringTheLoadModuleEvent()
$this->assertSame('oh, yeah baby!', $config['loaded']);
}

/**
* @group 5651
*/
public function testLoadingModuleFromAnotherModuleDemonstratesAppropriateSideEffects()
{
$configListener = $this->defaultListeners->getConfigListener();
$moduleManager = new ModuleManager(array('LoadOtherModule', 'BarModule'));
$moduleManager->getEventManager()->attachAggregate($this->defaultListeners);
$moduleManager->loadModules();

$config = $configListener->getMergedConfig();
$this->assertTrue(isset($config['baz']));
$this->assertSame('bar', $config['baz']);
}

public function testModuleIsMarkedAsLoadedWhenLoadModuleEventIsTriggered()
{
$test = new stdClass;
Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/BadConfigModule/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/BafModule/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/BamModule/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/BarModule/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
Loading

0 comments on commit 3b54f16

Please sign in to comment.