From 4365fb2a4115f043637e5a38e58f254af9a75085 Mon Sep 17 00:00:00 2001 From: blanchonvincent Date: Tue, 13 May 2014 17:07:18 +0200 Subject: [PATCH] Fix delegators property --- library/Zend/Mvc/Service/ServiceManagerConfig.php | 15 +++++++++++++++ .../Mvc/Service/ServiceManagerConfigTest.php | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/library/Zend/Mvc/Service/ServiceManagerConfig.php b/library/Zend/Mvc/Service/ServiceManagerConfig.php index 16066259d29..e580dad1247 100644 --- a/library/Zend/Mvc/Service/ServiceManagerConfig.php +++ b/library/Zend/Mvc/Service/ServiceManagerConfig.php @@ -65,6 +65,14 @@ class ServiceManagerConfig implements ConfigInterface 'EventManager' => false, ); + /** + * + * Delegators + * + * @var array + */ + protected $delegators = array(); + /** * Constructor * @@ -94,6 +102,9 @@ public function __construct(array $configuration = array()) $this->shared = array_merge($this->shared, $configuration['shared']); } + if (isset($configuration['delegators'])) { + $this->delegators = array_merge($this->delegators, $configuration['delegators']); + } } /** @@ -129,6 +140,10 @@ public function configureServiceManager(ServiceManager $serviceManager) $serviceManager->setShared($name, $value); } + foreach ($this->delegators as $name => $value) { + $serviceManager->addDelegator($name, $value); + } + $serviceManager->addInitializer(function ($instance) use ($serviceManager) { if ($instance instanceof EventManagerAwareInterface) { if ($instance->getEventManager() instanceof EventManagerInterface) { diff --git a/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php b/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php index 7334a8824ac..bd97128cab4 100644 --- a/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php +++ b/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php @@ -64,7 +64,7 @@ public function testCanAddDelegators() $config->configureServiceManager($sm); $std = $sm->get('foo'); - $this->assertInstanceOf('StdClass', $std); - $this->assertInstanceOf('baz', $std->bar); + $this->assertInstanceOf('stdClass', $std); + $this->assertEquals('baz', $std->bar); } }