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

Commit e263600

Browse files
committed
Remove ServiceLocatorAware implementation from AbstractController
`ServiceLocatorAwareInterface` was duck-typed in `AbstractController` previously; this commit removes that implementation.
1 parent 8fb0182 commit e263600

File tree

3 files changed

+0
-52
lines changed

3 files changed

+0
-52
lines changed

src/Controller/AbstractController.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Zend\Http\Request as HttpRequest;
1818
use Zend\Mvc\InjectApplicationEventInterface;
1919
use Zend\Mvc\MvcEvent;
20-
use Zend\ServiceManager\ServiceLocatorInterface;
2120
use Zend\ServiceManager\ServiceManager;
2221
use Zend\Stdlib\DispatchableInterface as Dispatchable;
2322
use Zend\Stdlib\RequestInterface as Request;
@@ -56,11 +55,6 @@ abstract class AbstractController implements
5655
*/
5756
protected $response;
5857

59-
/**
60-
* @var ServiceLocatorInterface
61-
*/
62-
protected $serviceLocator;
63-
6458
/**
6559
* @var Event
6660
*/
@@ -223,36 +217,6 @@ public function getEvent()
223217
return $this->event;
224218
}
225219

226-
/**
227-
* Set serviceManager instance
228-
*
229-
* @param ServiceLocatorInterface $serviceLocator
230-
* @return void
231-
*/
232-
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
233-
{
234-
$this->serviceLocator = $serviceLocator;
235-
}
236-
237-
/**
238-
* Retrieve serviceManager instance
239-
*
240-
* @return ServiceLocatorInterface
241-
*/
242-
public function getServiceLocator()
243-
{
244-
trigger_error(sprintf(
245-
'You are retrieving the service locator from within the class %s. Please be aware that '
246-
. 'ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along '
247-
. 'with the ServiceLocatorAwareInitializer. You will need to update your class to accept '
248-
. 'all dependencies at creation, either via constructor arguments or setters, and use '
249-
. 'a factory to perform the injections.',
250-
get_class($this)
251-
), E_USER_DEPRECATED);
252-
253-
return $this->serviceLocator;
254-
}
255-
256220
/**
257221
* Get plugin manager
258222
*

src/Service/ServiceManagerConfig.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
use Zend\ModuleManager\Listener\ServiceListener;
1919
use Zend\ModuleManager\ModuleManager;
2020
use Zend\ServiceManager\Config;
21-
use Zend\ServiceManager\ServiceLocatorAwareInterface;
2221
use Zend\ServiceManager\ServiceManager;
23-
use Zend\ServiceManager\ServiceManagerAwareInterface;
2422
use Zend\Stdlib\ArrayUtils;
2523

2624
class ServiceManagerConfig extends Config
@@ -68,8 +66,6 @@ class ServiceManagerConfig extends Config
6866
*
6967
* - factory for the service 'SharedEventManager'.
7068
* - initializer for EventManagerAwareInterface implementations
71-
* - initializer for ServiceManagerAwareInterface implementations
72-
* - initializer for ServiceLocatorAwareInterface implementations
7369
*
7470
* @param array $config
7571
*/

test/Controller/AbstractControllerTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use PHPUnit_Framework_TestCase as TestCase;
1313
use ReflectionProperty;
14-
use Zend\ServiceManager\ServiceLocatorInterface;
1514

1615
/**
1716
* @covers \Zend\Mvc\Controller\AbstractController
@@ -105,15 +104,4 @@ public function testSetEventManagerWithDefaultIdentifiersIncludesImplementedInte
105104

106105
$this->controller->setEventManager($eventManager);
107106
}
108-
109-
public function testRetrievingServiceLocatorRaisesDeprecationNotice()
110-
{
111-
$services = $this->prophesize(ServiceLocatorInterface::class)->reveal();
112-
113-
$controller = new TestAsset\SampleController();
114-
$controller->setServiceLocator($services);
115-
116-
$this->setExpectedException('PHPUnit_Framework_Error_Deprecated', 'retrieving the service locator');
117-
$controller->getServiceLocator();
118-
}
119107
}

0 commit comments

Comments
 (0)