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

Forwards compatibility with v3 releases #76

Merged
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
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,48 @@ cache:
directories:
- $HOME/.composer/cache

env:
global:
- EVENT_MANAGER_VERSION="^3.0"
- HYDRATOR_VERSION="^2.1"
- SERVICE_MANAGER_VERSION="^3.0.3"
- STDLIB_VERSION="^3.0"

matrix:
fast_finish: true
include:
- php: 5.5
env:
- EXECUTE_CS_CHECK=true
- php: 5.5
env:
- EVENT_MANAGER_VERSION="^2.6.2"
- HYDRATOR_VERSION="^1.1"
- SERVICE_MANAGER_VERSION="^2.7.5"
- STDLIB_VERSION="^2.7.5"
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- php: 5.6
env:
- EVENT_MANAGER_VERSION="^2.6.2"
- HYDRATOR_VERSION="^1.1"
- SERVICE_MANAGER_VERSION="^2.7.5"
- STDLIB_VERSION="^2.7.5"
- php: 7
- php: 7
env:
- EVENT_MANAGER_VERSION="^2.6.2"
- HYDRATOR_VERSION="^1.1"
- SERVICE_MANAGER_VERSION="^2.7.5"
- STDLIB_VERSION="^2.7.5"
- php: hhvm
- php: hhvm
env:
- EVENT_MANAGER_VERSION="^2.6.2"
- HYDRATOR_VERSION="^1.1"
- SERVICE_MANAGER_VERSION="^2.7.5"
- STDLIB_VERSION="^2.7.5"
allow_failures:
- php: hhvm

Expand All @@ -33,6 +64,7 @@ before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
- composer require --no-update "zendframework/zend-eventmanager:$EVENT_MANAGER_VERSION" "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" "zendframework/zend-hydrator:$HYDRATOR_VERSION" "zendframework/zend-stdlib:$STDLIB_VERSION"

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs
Expand Down
34 changes: 12 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 3.0.0 - TBD
## 2.7.0 - TBD

### Added

Expand Down Expand Up @@ -40,25 +40,20 @@ All notable changes to this project will be documented in this file, in reverse

### Deprecated

- Nothing.
- Two initializers registered by `Zend\Mvc\Service\ServiceManagerConfig` are now
deprecated, and will be removed starting in version 3.0:
- `ServiceManagerAwareInitializer`, which injects classes implementing
`Zend\ServiceManager\ServiceManagerAwareInterface` with the service manager
instance. Users should create factories for such classes that directly
inject their dependencies instead.
- `ServiceLocatorAwareInitializer`, which injects classes implementing
`Zend\ServiceManager\ServiceLocatorAwareInterface` with the service manager
instance. Users should create factories for such classes that directly
inject their dependencies instead.

### Removed

- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
`Zend\Mvc\Service\ConfigFactory`, as the functionality is now incorporated
into `Zend\ModuleManager\Listener\ServiceListener`.
- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
the `ServiceLocatorAware` intializer, as zend-servicemanager v3 no longer
defines the interface.
- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
`Zend\Mvc\Service\ControllerLoaderFactory` and replaces it with
`Zend\Mvc\Service\ControllerManagerFactory`.
- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
`Zend\Mvc\Service\DiFactory`, `Zend\Mvc\Service\DiAbstractServiceFactory`,
`Zend\Mvc\Service\DiStrictAbstractServiceFactory`,
`Zend\Mvc\Service\DiStrictAbstractServiceFactoryFactory`,
and `Zend\Mvc\Service\DiServiceInitializerFactory`, as zend-servicemanager v3
removes `Zend\Di` integration.
- Nothing.

### Fixed

Expand All @@ -85,11 +80,6 @@ All notable changes to this project will be documented in this file, in reverse
`Zend\ModuleManager\Listener\ServiceListener` instance before retrieving and
bootstrapping the `Application` instance; this ensure it is fully
configured at that time.
- [#38](https://github.com/zendframework/zend-mvc/pull/38) Ensure middleware
tests against abstract factories
- zend-servicemanager v3 modified the behavior of has() to not search abstract
factories by default. You can force it to do so by passing an optional
second argument, a boolean flag, with a value of boolean true.

## 2.6.4 - TBD

Expand Down
50 changes: 24 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@
},
"require": {
"php": "^5.5 || ^7.0",
"zendframework/zend-eventmanager": "dev-develop as 2.7.0",
"zendframework/zend-servicemanager": "dev-develop as 2.6.0",
"zendframework/zend-hydrator": "~1.0",
"zendframework/zend-form": "~2.6",
"zendframework/zend-stdlib": "^2.7.5",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-hydrator": "^1.1 || ^2.1",
"zendframework/zend-form": "^2.7",
"zendframework/zend-stdlib": "^2.7.5 || ^3.0",
"zendframework/zend-psr7bridge": "^0.2",
"container-interop/container-interop": "^1.1"
},
"require-dev": {
"zendframework/zend-authentication": "~2.5",
"zendframework/zend-cache": "~2.5",
"zendframework/zend-console": "~2.5",
"zendframework/zend-di": "~2.5",
"zendframework/zend-filter": "~2.5",
"zendframework/zend-http": "~2.5",
"zendframework/zend-i18n": "~2.5",
"zendframework/zend-inputfilter": "~2.5",
"zendframework/zend-json": "~2.5",
"zendframework/zend-log": "~2.5",
"zendframework/zend-modulemanager": "dev-develop as 2.7.0",
"zendframework/zend-session": "~2.5",
"zendframework/zend-serializer": "~2.5",
"zendframework/zend-text": "~2.5",
"zendframework/zend-uri": "~2.5",
"zendframework/zend-validator": "~2.5",
"zendframework/zend-version": "~2.5",
"zendframework/zend-view": "dev-develop as 2.6.0",
"zendframework/zend-authentication": "^2.5.3",
"zendframework/zend-cache": "^2.6.1",
"zendframework/zend-console": "^2.6",
"zendframework/zend-di": "^2.6",
"zendframework/zend-filter": "^2.6.1",
"zendframework/zend-http": "^2.5.4",
"zendframework/zend-i18n": "^2.6",
"zendframework/zend-inputfilter": "^2.6",
"zendframework/zend-json": "^2.6.1",
"zendframework/zend-log": "^2.7.1",
"zendframework/zend-modulemanager": "^2.7.1",
"zendframework/zend-session": "^2.6.2",
"zendframework/zend-serializer": "^2.6.1",
"zendframework/zend-text": "^2.6",
"zendframework/zend-uri": "^2.5",
"zendframework/zend-validator": "^2.6",
"zendframework/zend-version": "^2.5",
"zendframework/zend-view": "^2.6.3",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
},
Expand All @@ -64,12 +64,10 @@
"zendframework/zend-version": "Zend\\Version component",
"zendframework/zend-view": "Zend\\View component"
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "2.6-dev",
"dev-develop": "3.0-dev"
"dev-develop": "2.7-dev"
}
},
"autoload-dev": {
Expand Down
36 changes: 19 additions & 17 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,22 @@ class Application implements
*
* @param mixed $configuration
* @param ServiceManager $serviceManager
* @param null|EventManagerInterface $events
* @param null|RequestInterface $request
* @param null|ResponseInterface $response
*/
public function __construct(
$configuration,
ServiceManager $serviceManager,
EventManagerInterface $events,
RequestInterface $request,
ResponseInterface $response
EventManagerInterface $events = null,
RequestInterface $request = null,
ResponseInterface $response = null
) {
$this->configuration = $configuration;
$this->serviceManager = $serviceManager;
$this->setEventManager($events);
$this->request = $request;
$this->response = $response;
$this->setEventManager($events ?: $serviceManager->get('EventManager'));
$this->request = $request ?: $serviceManager->get('Request');
$this->response = $response ?: $serviceManager->get('Response');
}

/**
Expand All @@ -143,8 +146,8 @@ public function getConfig()
*/
public function bootstrap(array $listeners = [])
{
$events = $this->events;
$serviceManager = $this->serviceManager;
$events = $this->events;

// Setup default listeners
$listeners = array_unique(array_merge($this->defaultListeners, $listeners));
Expand Down Expand Up @@ -261,20 +264,13 @@ public static function init($configuration = [])
$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : [];
$smConfig = new Service\ServiceManagerConfig($smConfig);

$serviceManager = new ServiceManager($smConfig->toArray());
$serviceManager = $serviceManager->withConfig(['services' => [
'ApplicationConfig' => $configuration,
]]);
$serviceManager = new ServiceManager();
$smConfig->configureServiceManager($serviceManager);
$serviceManager->setService('ApplicationConfig', $configuration);

// Load modules
$serviceManager->get('ModuleManager')->loadModules();

// Get the configured SM if necessary.
if ($serviceManager->has('ServiceListener')) {
$serviceListener = $serviceManager->get('ServiceListener');
$serviceManager = $serviceListener->getConfiguredServiceManager();
}

// Prepare list of listeners to bootstrap
$listenersFromAppConfig = isset($configuration['listeners']) ? $configuration['listeners'] : [];
$config = $serviceManager->get('config');
Expand Down Expand Up @@ -319,13 +315,15 @@ public function run()

// Trigger route event
$event->setName(MvcEvent::EVENT_ROUTE);
$event->stopPropagation(false); // Clear before triggering
$result = $events->triggerEventUntil($shortCircuit, $event);
if ($result->stopped()) {
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setName(MvcEvent::EVENT_FINISH);
$event->setTarget($this);
$event->setResponse($response);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);
$this->response = $response;
return $this;
Expand All @@ -338,6 +336,7 @@ public function run()

// Trigger dispatch event
$event->setName(MvcEvent::EVENT_DISPATCH);
$event->stopPropagation(false); // Clear before triggering
$result = $events->triggerEventUntil($shortCircuit, $event);

// Complete response
Expand All @@ -346,6 +345,7 @@ public function run()
$event->setName(MvcEvent::EVENT_FINISH);
$event->setTarget($this);
$event->setResponse($response);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);
$this->response = $response;
return $this;
Expand Down Expand Up @@ -380,9 +380,11 @@ protected function completeRequest(MvcEvent $event)
$event->setTarget($this);

$event->setName(MvcEvent::EVENT_RENDER);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);

$event->setName(MvcEvent::EVENT_FINISH);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);

return $this;
Expand Down
Loading