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

Commit

Permalink
Merge branch 'feature/forwards-compat' into develop
Browse files Browse the repository at this point in the history
Close #76
  • Loading branch information
weierophinney committed Feb 28, 2016
2 parents 21376dc + f34acf5 commit 45d259c
Show file tree
Hide file tree
Showing 100 changed files with 2,482 additions and 695 deletions.
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
68 changes: 25 additions & 43 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

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

- [#31](https://github.com/zendframework/zend-mvc/pull/31) adds three required
arguments to the `Zend\Mvc\Application` constructor: an EventManager
- [#31](https://github.com/zendframework/zend-mvc/pull/31) adds three new
optional arguments to the `Zend\Mvc\Application` constructor: an EventManager
instance, a Request instance, and a Response instance.
- [#36](https://github.com/zendframework/zend-mvc/pull/36) adds more than a
dozen service factories, primarily to separate conditional factories into
Expand Down Expand Up @@ -40,56 +40,38 @@ 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

- [#31](https://github.com/zendframework/zend-mvc/pull/31) updates the component
to use zend-eventmanager v3.
- [#36](https://github.com/zendframework/zend-mvc/pull/36) updates the component
to use zend-servicemanager v3, and zend-modulemanager v3. This involves:
- Updating all factories implementing either `FactoryInterface` or
`AbstractFactoryInterface` to the new signatures of those interfaces.
- Updating all plugin managers to the updates to `AbstractPluginManager`.
- Updating how plugin manager factories work (they're now passed the container
instance in their constructor arguments, as well as any build options).
- [#31](https://github.com/zendframework/zend-mvc/pull/31) and
[#76](https://github.com/zendframework/zend-mvc/pull/76) update the component
to be forwards-compatible with zend-eventmanager v3.
- [#36](https://github.com/zendframework/zend-mvc/pull/36) and
[#76](https://github.com/zendframework/zend-mvc/pull/76) update the component
to be forwards-compatible with zend-servicemanager v3. Several changes were
introduced to support this effort:
- Added a `RouteInvokableFactory`, which can act as either a
`FactoryInterface` or `AbstractFactoryInterface` for loading invokable route
classes, including by fully qualified class name. This is registered as an
abstract factory by default with the `RoutePluginManager`.
`FactoryInterface` or `AbstractFactoryInterface` for loading invokable route
classes, including by fully qualified class name. This is registered as an
abstract factory by default with the `RoutePluginManager`.
- The `DispatchListener` now receives the controller manager instance at
instantiation.
- The `ViewManager` implementations were updated, and most functionality
within separated into discrete factories. (Previously these instances
injected services and aliases into the service manager instance, which is no
longer possible or desirable with the zend-servicemanager v3 changes.)
- `Application::init()` now pulls the configured service manager from the
`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.
within separated into discrete factories.

## 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

0 comments on commit 45d259c

Please sign in to comment.