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

Remove deprecated functionality #128

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,15 @@ env:
matrix:
fast_finish: true
include:
- php: 5.5
env:
- DEPS=lowest
- php: 5.5
env:
- DEPS=locked
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- php: 5.5
env:
- DEPS=latest
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=locked
- TEST_COVERAGE=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- php: 5.6
env:
- DEPS=latest
Expand Down
15 changes: 5 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
}
},
"require": {
"php": "^5.5 || ^7.0",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"php": "^5.6 || ^7.0",
"zendframework/zend-eventmanager": "^3.0",
"zendframework/zend-http": "^2.5.4",
"zendframework/zend-modulemanager": "^2.7.1",
"zendframework/zend-router": "^3.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-stdlib": "^2.7.5 || ^3.0",
"zendframework/zend-servicemanager": "^3.0.3",
"zendframework/zend-stdlib": "^3.0",
"zendframework/zend-view": "^2.6.3",
"container-interop/container-interop": "^1.1"
},
Expand All @@ -30,20 +30,15 @@
"phpunit/phpunit": "^4.5"
},
"suggest": {
"zendframework/zend-config": "Zend\\Config component",
"zendframework/zend-di": "Zend\\Di component",
"zendframework/zend-http": "Zend\\Http component",
"zendframework/zend-json": "(^2.6.1 || ^3.0) To auto-deserialize JSON body content in AbstractRestfulController extensions, when json_decode is unavailable",
"zendframework/zend-modulemanager": "Zend\\ModuleManager component",
"zendframework/zend-mvc-console": "zend-mvc-console provides the ability to expose zend-mvc as a console application",
"zendframework/zend-mvc-i18n": "zend-mvc-i18n provides integration with zend-i18n, including a translation bridge and translatable route segments",
"zendframework/zend-mvc-plugin-fileprg": "To provide Post/Redirect/Get functionality around forms that container file uploads",
"zendframework/zend-mvc-plugin-flashmessenger": "To provide flash messaging capabilities between requests",
"zendframework/zend-mvc-plugin-identity": "To access the authenticated identity (per zend-authentication) in controllers",
"zendframework/zend-mvc-plugin-prg": "To provide Post/Redirect/Get functionality within controllers",
"zendframework/zend-psr7bridge": "(^0.2) To consume PSR-7 middleware within the MVC workflow",
"zendframework/zend-servicemanager-di": "zend-servicemanager-di provides utilities for integrating zend-di and zend-servicemanager in your zend-mvc application",
"zendframework/zend-view": "Zend\\View component"
"zendframework/zend-servicemanager-di": "zend-servicemanager-di provides utilities for integrating zend-di and zend-servicemanager in your zend-mvc application"
},
"extra": {
"branch-alias": {
Expand Down
59 changes: 59 additions & 0 deletions doc/book/migration/to-v3-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ your application configuration. Components are pushed to the top of the module
list, while modules are pushed to the end. As a development component, it will
not be installed in your production distributions.

## Updated dependencies

The v3 release now *requires*:

- zend-http
- zend-modulemanager
- zend-router
- zend-view

Additionally, the following components require their v3 releases:

- zend-eventmanager
- zend-servicemanager
- zend-stdlib

The minimum supported PHP version was bumped to 5.6.

## Application class

The following changes were made to the `Zend\Mvc\Application` constructor:
Expand All @@ -49,6 +66,20 @@ will not notice a change. Those who are directly instantiating the `Application`
instance (in production or test code) or who have created their own factory for
the class will need to update their code.

### send method

The `send()` method has been deprecated since the 2.2 release, and a no-op since
then as well. It is removed starting with the v3 release.

## ControllerLoader

The `ControllerLoader` service was deprecated early in the v2 lifecycle, and
aliased to `ControllerManager`. The `ControllerLoader` factory was kept to
prevent BC breaks due to extending the class.

v3 removes the `ControllerLoaderFactory`, as well as the `ControllerLoader`
service alias.

## DI-ServiceManager integration

The integration between [zend-servicemanager](https://zendframework.github.io/zend-servicemanager) and
Expand All @@ -71,6 +102,12 @@ $ composer require zendframework/zend-servicemanager-di
The new component also contains a [migration document](https://zendframework.github.io/zend-servicemanager-di/migration/v2-to-v3/)
detailing potential issues for users migrating to version 3.

## DispatchListener

The `marshallControllerNotFoundEvent()` method was deprecated early in the ZF2
lifecycle, and has proxied to `marshalControllerNotFoundEvent()`. It is removed
with the v3 release.

## Routing

Routing was removed from zend-mvc, and moved to a new component,
Expand Down Expand Up @@ -340,6 +377,22 @@ $ composer require zendframework/zend-serializer
Note: the above assumes you have already installed zend-component-installer, per
the section above on [dependency reduction](#dependency-reduction).

## ServiceLocatorAware initializers

Starting with zend-servicemanager v3, that component no longer defines the
`ServiceLocatorAwareInterface`. Since zend-mvc pins against zend-servicemanager
v3 with its own v3 release, the initializers that injected the application
container into implementations of that interface are no longer relevant. As
such, they have now been removed from each of the
`Zend\Mvc\Service\ServiceManagerConfig` and
`Zend\Mvc\Controller\ControllerManager` classes.

Additionally, the duck-typed `ServiceLocatorAwareInterface` implementation in
`AbstractController` was removed, as messaged in the 2.7 release.

If you relied on this functionality, you are encouraged to update your code to
use factories to inject your *actual* dependencies.

## Validator integration

In version 2, zend-mvc exposed a `ValidatorManager` service by default, and
Expand All @@ -356,3 +409,9 @@ $ composer require zendframework/zend-validator

Note: the above assumes you have already installed zend-component-installer, per
the section above on [dependency reduction](#dependency-reduction).

## Zend\Mvc\View\SendResponseListener

`Zend\Mvc\View\SendResponseListener` was deprecated with the 2.2 release, and
has been an extension of `Zend\Mvc\SendResponseListener` ever since. It is
removed with the v3 release.
7 changes: 0 additions & 7 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,6 @@ public function run()
return $this;
}

/**
* @deprecated
*/
public function send()
{
}

/**
* Complete the request
*
Expand Down
36 changes: 0 additions & 36 deletions src/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Zend\Http\Request as HttpRequest;
use Zend\Mvc\InjectApplicationEventInterface;
use Zend\Mvc\MvcEvent;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\Stdlib\DispatchableInterface as Dispatchable;
use Zend\Stdlib\RequestInterface as Request;
Expand Down Expand Up @@ -56,11 +55,6 @@ abstract class AbstractController implements
*/
protected $response;

/**
* @var ServiceLocatorInterface
*/
protected $serviceLocator;

/**
* @var Event
*/
Expand Down Expand Up @@ -223,36 +217,6 @@ public function getEvent()
return $this->event;
}

/**
* Set serviceManager instance
*
* @param ServiceLocatorInterface $serviceLocator
* @return void
*/
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
}

/**
* Retrieve serviceManager instance
*
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
trigger_error(sprintf(
'You are retrieving the service locator from within the class %s. Please be aware that '
. 'ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along '
. 'with the ServiceLocatorAwareInitializer. You will need to update your class to accept '
. 'all dependencies at creation, either via constructor arguments or setters, and use '
. 'a factory to perform the injections.',
get_class($this)
), E_USER_DEPRECATED);

return $this->serviceLocator;
}

/**
* Get plugin manager
*
Expand Down
53 changes: 0 additions & 53 deletions src/Controller/ControllerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Zend\ServiceManager\AbstractPluginManager;
use Zend\ServiceManager\ConfigInterface;
use Zend\ServiceManager\Exception\InvalidServiceException;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\Stdlib\DispatchableInterface;

/**
Expand Down Expand Up @@ -54,10 +53,6 @@ public function __construct($configOrContainerInstance, array $v3config = [])
$this->addInitializer([$this, 'injectEventManager']);
$this->addInitializer([$this, 'injectPluginManager']);
parent::__construct($configOrContainerInstance, $v3config);

// Added after parent construction, as v2 abstract plugin managers add
// one during construction.
$this->addInitializer([$this, 'injectServiceLocator']);
}

/**
Expand Down Expand Up @@ -165,52 +160,4 @@ public function injectPluginManager($first, $second)

$controller->setPluginManager($container->get('ControllerPluginManager'));
}

/**
* Initializer: inject service locator
*
* @param ContainerInterface|DispatchableInterface $first Container when
* using zend-servicemanager v3; controller under v2.
* @param DispatchableInterface|ContainerInterface $second Controller when
* using zend-servicemanager v3; container under v2.
*/
public function injectServiceLocator($first, $second)
{
if ($first instanceof ContainerInterface) {
$container = $first;
$controller = $second;
} else {
$container = $second;
$controller = $first;
}

// For v2, we need to pull the parent service locator
if (! method_exists($container, 'configure')) {
$container = $container->getServiceLocator() ?: $container;
}

// Inject AbstractController extensions that are not ServiceLocatorAware
// with the service manager, but do not emit a deprecation notice. We'll
// emit it from AbstractController::getServiceLocator() instead.
if (! $controller instanceof ServiceLocatorAwareInterface
&& $controller instanceof AbstractController
&& method_exists($controller, 'setServiceLocator')
) {
// Do not emit deprecation notice in this case
$controller->setServiceLocator($container);
}

// If a controller implements ServiceLocatorAwareInterface explicitly, we
// inject, but emit a deprecation notice. Since AbstractController no longer
// explicitly does this, this will only affect userland controllers.
if ($controller instanceof ServiceLocatorAwareInterface) {
trigger_error(sprintf(
'ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along '
. 'with the ServiceLocatorAwareInitializer. Please update your class %s to remove '
. 'the implementation, and start injecting your dependencies via factory instead.',
get_class($controller)
), E_USER_DEPRECATED);
$controller->setServiceLocator($container);
}
}
}
27 changes: 0 additions & 27 deletions src/DispatchListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,33 +193,6 @@ protected function marshalControllerNotFoundEvent(
return $return;
}

/**
* Marshal a controller not found exception event
*
* @deprecated Use marshalControllerNotFoundEvent() instead
* @param string $type
* @param string $controllerName
* @param MvcEvent $event
* @param Application $application
* @param \Exception $exception
* @return mixed
*/
protected function marshallControllerNotFoundEvent(
$type,
$controllerName,
MvcEvent $event,
Application $application,
\Exception $exception = null
) {
trigger_error(sprintf(
'%s is deprecated; please use %s::marshalControllerNotFoundEvent instead',
__METHOD__,
__CLASS__
), E_USER_DEPRECATED);

return $this->marshalControllerNotFoundEvent($type, $controllerName, $event, $application, $exception);
}

/**
* Marshal a bad controller exception event
*
Expand Down
48 changes: 0 additions & 48 deletions src/Service/ControllerLoaderFactory.php

This file was deleted.

1 change: 0 additions & 1 deletion src/Service/ServiceListenerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class ServiceListenerFactory implements FactoryInterface
'aliases' => [
'configuration' => 'config',
'Configuration' => 'config',
'ControllerLoader' => 'ControllerManager',
'HttpDefaultRenderingStrategy' => View\Http\DefaultRenderingStrategy::class,
'MiddlewareListener' => 'Zend\Mvc\MiddlewareListener',
'RouteListener' => 'Zend\Mvc\RouteListener',
Expand Down
Loading