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

Commit

Permalink
Merge branch 'hotfix/36'
Browse files Browse the repository at this point in the history
Close #36
  • Loading branch information
weierophinney committed Jul 11, 2017
2 parents 77e20c0 + ef00acf commit 2a258e4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
24 changes: 6 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.8.0 - TBD

### Added

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 2.7.3 - TBD

### Added
Expand All @@ -38,6 +20,12 @@ All notable changes to this project will be documented in this file, in reverse

- [#53](https://github.com/zendframework/zend-modulemanager/pull/53) preventing race conditions
when writing cache files (merged configuration)
- [#36](https://github.com/zendframework/zend-modulemanager/pull/36) removes a
throw from `ServiceListener::onLoadModulesPost()` that was previously emitted
when a named plugin manager did not have an associated service present yet.
Doing so allows plugin managers to be registered after configuration is fully
merged, instead of requiring they be defined early. This change allows
components to define their plugin managers via their `Module` classes.

## 2.7.2 - 2016-05-16

Expand Down
6 changes: 2 additions & 4 deletions src/Listener/ServiceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,8 @@ public function onLoadModulesPost(ModuleEvent $e)

if (! $sm['service_manager'] instanceof ServiceManager) {
if (! $this->defaultServiceManager->has($sm['service_manager'])) {
throw new Exception\RuntimeException(sprintf(
'Could not find a valid ServiceManager for %s',
$sm['service_manager']
));
// No plugin manager registered by that name; nothing to configure.
continue;
}

$instance = $this->defaultServiceManager->get($sm['service_manager']);
Expand Down
29 changes: 29 additions & 0 deletions test/Listener/ServiceListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,33 @@ public function testListenerCanOverrideServicesInServiceManagers()
$this->assertEquals(['foo' => 'bar'], $services->get('config'), 'Config service was not overridden');
$this->assertInstanceOf(stdClass::class, $services->get('foo'), 'Foo service was not overridden');
}

public function testOnLoadModulesPostShouldNotRaiseExceptionIfNamedServiceManagerDoesNotExist()
{
$services = new ServiceManager();
$services->setService('config', []);
$listener = new ServiceListener($services);
$listener->addServiceManager(
'UndefinedPluginManager',
'undefined',
TestAsset\UndefinedProviderInterface::class,
'getUndefinedConfig'
);

$module = new TestAsset\ServiceProviderModule([]);

$event = new ModuleEvent();
$configListener = new ConfigListener();
$event->setConfigListener($configListener);

$event->setModule($module);
$listener->onLoadModule($event);

try {
$listener->onLoadModulesPost($event);
$this->assertFalse($services->has('UndefinedPluginManager'));
} catch (\Exception $e) {
$this->fail('Exception should not be raised when encountering unknown plugin manager services');
}
}
}
13 changes: 13 additions & 0 deletions test/Listener/TestAsset/UndefinedProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* @link http://github.com/zendframework/zend-modulemanager for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\ModuleManager\Listener\TestAsset;

interface UndefinedProviderInterface
{
public function getUndefinedConfig();
}

0 comments on commit 2a258e4

Please sign in to comment.