Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Fix delegators property
Browse files Browse the repository at this point in the history
  • Loading branch information
blanchonvincent committed May 13, 2014
1 parent aa6f1d3 commit 4365fb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions library/Zend/Mvc/Service/ServiceManagerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ class ServiceManagerConfig implements ConfigInterface
'EventManager' => false,
);

/**
*
* Delegators
*
* @var array
*/
protected $delegators = array();

/**
* Constructor
*
Expand Down Expand Up @@ -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']);
}
}

/**
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 4365fb2

Please sign in to comment.