Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renaming 'delegates' => 'delegators'

  • Loading branch information...
commit 32bd19d4d468fb147977a74d3ab9404252e10dc4 1 parent 020b28a
@Ocramius authored
View
13 library/Zend/ServiceManager/Config.php
@@ -107,13 +107,14 @@ public function getShared()
}
/**
- * Get delegate services map, with keys being the services, and values being the delegate factories names
+ * Get the delegator services map, with keys being the services acting as delegates,
+ * and values being the delegator factories names
*
* @return array
*/
- public function getDelegates()
+ public function getDelegators()
{
- return (isset($this->config['delegates'])) ? $this->config['delegates'] : array();
+ return (isset($this->config['delegators'])) ? $this->config['delegators'] : array();
}
/**
@@ -156,9 +157,9 @@ public function configureServiceManager(ServiceManager $serviceManager)
$serviceManager->setShared($name, $isShared);
}
- foreach ($this->getDelegates() as $name => $delegates) {
- foreach ($delegates as $delegate) {
- $serviceManager->addDelegate($name, $delegate);
+ foreach ($this->getDelegators() as $originalServiceName => $delegators) {
+ foreach ($delegators as $delegator) {
+ $serviceManager->addDelegator($originalServiceName, $delegator);
}
}
}
View
4 ...rviceManager/DelegateFactoryInterface.php → ...viceManager/DelegatorFactoryInterface.php
@@ -12,7 +12,7 @@
/**
* Interface for factories that can create delegates for services
*/
-interface DelegateFactoryInterface
+interface DelegatorFactoryInterface
{
/**
* A factory that creates delegates of a given service
@@ -24,5 +24,5 @@
*
* @return mixed
*/
- public function createDelegateWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback);
+ public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback);
}
View
32 library/Zend/ServiceManager/ServiceManager.php
@@ -51,7 +51,7 @@ class ServiceManager implements ServiceLocatorInterface
/**
* @var array[]
*/
- protected $delegates = array();
+ protected $delegators = array();
/**
* @var array
@@ -317,20 +317,20 @@ public function addAbstractFactory($factory, $topOfStack = true)
}
/**
- * Sets the given service name as to be handled by a delegate factory
+ * Sets the given service name as to be handled by a delegator factory
*
- * @param string $serviceName
- * @param string $delegateFactoryName
+ * @param string $serviceName name of the service being the delegate
+ * @param string $delegatorFactoryName name of the service being the delegator factory
*
* @return ServiceManager
*/
- public function addDelegate($serviceName, $delegateFactoryName)
+ public function addDelegator($serviceName, $delegatorFactoryName)
{
- if (!isset($this->delegates[$this->canonicalizeName($serviceName)])) {
- $this->delegates[$this->canonicalizeName($serviceName)] = array();
+ if (!isset($this->delegators[$this->canonicalizeName($serviceName)])) {
+ $this->delegators[$this->canonicalizeName($serviceName)] = array();
}
- $this->delegates[$this->canonicalizeName($serviceName)][] = $delegateFactoryName;
+ $this->delegators[$this->canonicalizeName($serviceName)][] = $delegatorFactoryName;
return $this;
}
@@ -520,26 +520,26 @@ public function create($name)
}
}
- if (isset($this->delegates[$cName])) {
+ if (isset($this->delegators[$cName])) {
$serviceManager = $this;
- $additionalDelegates = count($this->delegates[$cName]) - 1;
+ $additionalDelegates = count($this->delegators[$cName]) - 1;
$creationCallback = function () use ($serviceManager, $rName, $cName) {
return $serviceManager->doCreate($rName, $cName);
};
for ($i = 0; $i < $additionalDelegates; $i += 1) {
$creationCallback = $this->createDelegateCallback(
- $this->delegates[$cName][$i],
+ $this->delegators[$cName][$i],
$rName,
$cName,
$creationCallback
);
}
- /* @var $delegateFactory DelegateFactoryInterface */
- $delegateFactory = $this->get($this->delegates[$cName][$i]);
+ /* @var $delegateFactory DelegatorFactoryInterface */
+ $delegateFactory = $this->get($this->delegators[$cName][$i]);
- return $delegateFactory->createDelegateWithName($this, $cName, $rName, $creationCallback);
+ return $delegateFactory->createDelegatorWithName($this, $cName, $rName, $creationCallback);
}
return $this->doCreate($rName, $cName);
@@ -560,10 +560,10 @@ private function createDelegateCallback($delegateFactoryName, $rName, $cName, $c
$serviceManager = $this;
return function () use ($serviceManager, $delegateFactoryName, $rName, $cName, $creationCallback) {
- /* @var $delegateFactory DelegateFactoryInterface */
+ /* @var $delegateFactory DelegatorFactoryInterface */
$delegateFactory = $serviceManager->get($delegateFactoryName);
- return $delegateFactory->createDelegateWithName($serviceManager, $cName, $rName, $creationCallback);
+ return $delegateFactory->createDelegatorWithName($serviceManager, $cName, $rName, $creationCallback);
};
}
View
10 tests/ZendTest/ServiceManager/ServiceManagerTest.php
@@ -737,15 +737,15 @@ public function testRetrieveServiceFromPeeringServiceManagerIfretrieveFromPeerin
*/
public function testUsesDelegateWhenAvailable()
{
- $delegate = $this->getMock('Zend\\ServiceManager\\DelegateFactoryInterface');
+ $delegate = $this->getMock('Zend\\ServiceManager\\DelegatorFactoryInterface');
$this->serviceManager->setService('foo-delegate', $delegate);
- $this->serviceManager->addDelegate('foo-service', 'foo-delegate');
+ $this->serviceManager->addDelegator('foo-service', 'foo-delegate');
$this->serviceManager->setInvokableClass('foo-service', 'stdClass');
$delegate
->expects($this->once())
- ->method('createDelegateWithName')
+ ->method('createDelegatorWithName')
->with(
$this->serviceManager,
'fooservice',
@@ -777,8 +777,8 @@ public function testUsesMultipleDelegates()
$this->serviceManager->setService('foo-delegate', $fooDelegate);
$this->serviceManager->setService('bar-delegate', $barDelegate);
- $this->serviceManager->addDelegate('foo-service', 'foo-delegate');
- $this->serviceManager->addDelegate('foo-service', 'bar-delegate');
+ $this->serviceManager->addDelegator('foo-service', 'foo-delegate');
+ $this->serviceManager->addDelegator('foo-service', 'bar-delegate');
$this->serviceManager->setInvokableClass('foo-service', 'stdClass');
$this->assertSame($barDelegate, $this->serviceManager->create('foo-service'));
View
6 tests/ZendTest/ServiceManager/TestAsset/MockSelfReturningDelegateFactory.php
@@ -10,13 +10,13 @@
namespace ZendTest\ServiceManager\TestAsset;
-use Zend\ServiceManager\DelegateFactoryInterface;
+use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Mock factory that logs delegated instances and returns itself
*/
-class MockSelfReturningDelegateFactory implements DelegateFactoryInterface
+class MockSelfReturningDelegateFactory implements DelegatorFactoryInterface
{
/**
* @var mixed[]
@@ -26,7 +26,7 @@ class MockSelfReturningDelegateFactory implements DelegateFactoryInterface
/**
* {@inheritDoc}
*/
- public function createDelegateWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
+ public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
{
$this->instances[] = call_user_func($callback);
Please sign in to comment.
Something went wrong with that request. Please try again.