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

Commit 45d259c

Browse files
committed
Merge branch 'feature/forwards-compat' into develop
Close #76
2 parents 21376dc + f34acf5 commit 45d259c

File tree

100 files changed

+2482
-695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2482
-695
lines changed

.travis.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,48 @@ cache:
1111
directories:
1212
- $HOME/.composer/cache
1313

14+
env:
15+
global:
16+
- EVENT_MANAGER_VERSION="^3.0"
17+
- HYDRATOR_VERSION="^2.1"
18+
- SERVICE_MANAGER_VERSION="^3.0.3"
19+
- STDLIB_VERSION="^3.0"
20+
1421
matrix:
1522
fast_finish: true
1623
include:
1724
- php: 5.5
1825
env:
1926
- EXECUTE_CS_CHECK=true
27+
- php: 5.5
28+
env:
29+
- EVENT_MANAGER_VERSION="^2.6.2"
30+
- HYDRATOR_VERSION="^1.1"
31+
- SERVICE_MANAGER_VERSION="^2.7.5"
32+
- STDLIB_VERSION="^2.7.5"
2033
- php: 5.6
2134
env:
2235
- EXECUTE_TEST_COVERALLS=true
36+
- php: 5.6
37+
env:
38+
- EVENT_MANAGER_VERSION="^2.6.2"
39+
- HYDRATOR_VERSION="^1.1"
40+
- SERVICE_MANAGER_VERSION="^2.7.5"
41+
- STDLIB_VERSION="^2.7.5"
2342
- php: 7
43+
- php: 7
44+
env:
45+
- EVENT_MANAGER_VERSION="^2.6.2"
46+
- HYDRATOR_VERSION="^1.1"
47+
- SERVICE_MANAGER_VERSION="^2.7.5"
48+
- STDLIB_VERSION="^2.7.5"
2449
- php: hhvm
50+
- php: hhvm
51+
env:
52+
- EVENT_MANAGER_VERSION="^2.6.2"
53+
- HYDRATOR_VERSION="^1.1"
54+
- SERVICE_MANAGER_VERSION="^2.7.5"
55+
- STDLIB_VERSION="^2.7.5"
2556
allow_failures:
2657
- php: hhvm
2758

@@ -33,6 +64,7 @@ before_install:
3364
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
3465
- composer self-update
3566
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
67+
- 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"
3668

3769
install:
3870
- travis_retry composer install --no-interaction --ignore-platform-reqs

CHANGELOG.md

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

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

5-
## 3.0.0 - TBD
5+
## 2.7.0 - TBD
66

77
### Added
88

9-
- [#31](https://github.com/zendframework/zend-mvc/pull/31) adds three required
10-
arguments to the `Zend\Mvc\Application` constructor: an EventManager
9+
- [#31](https://github.com/zendframework/zend-mvc/pull/31) adds three new
10+
optional arguments to the `Zend\Mvc\Application` constructor: an EventManager
1111
instance, a Request instance, and a Response instance.
1212
- [#36](https://github.com/zendframework/zend-mvc/pull/36) adds more than a
1313
dozen service factories, primarily to separate conditional factories into
@@ -40,56 +40,38 @@ All notable changes to this project will be documented in this file, in reverse
4040

4141
### Deprecated
4242

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

4554
### Removed
4655

47-
- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
48-
`Zend\Mvc\Service\ConfigFactory`, as the functionality is now incorporated
49-
into `Zend\ModuleManager\Listener\ServiceListener`.
50-
- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
51-
the `ServiceLocatorAware` intializer, as zend-servicemanager v3 no longer
52-
defines the interface.
53-
- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
54-
`Zend\Mvc\Service\ControllerLoaderFactory` and replaces it with
55-
`Zend\Mvc\Service\ControllerManagerFactory`.
56-
- [#36](https://github.com/zendframework/zend-mvc/pull/36) removes
57-
`Zend\Mvc\Service\DiFactory`, `Zend\Mvc\Service\DiAbstractServiceFactory`,
58-
`Zend\Mvc\Service\DiStrictAbstractServiceFactory`,
59-
`Zend\Mvc\Service\DiStrictAbstractServiceFactoryFactory`,
60-
and `Zend\Mvc\Service\DiServiceInitializerFactory`, as zend-servicemanager v3
61-
removes `Zend\Di` integration.
56+
- Nothing.
6257

6358
### Fixed
6459

65-
- [#31](https://github.com/zendframework/zend-mvc/pull/31) updates the component
66-
to use zend-eventmanager v3.
67-
- [#36](https://github.com/zendframework/zend-mvc/pull/36) updates the component
68-
to use zend-servicemanager v3, and zend-modulemanager v3. This involves:
69-
- Updating all factories implementing either `FactoryInterface` or
70-
`AbstractFactoryInterface` to the new signatures of those interfaces.
71-
- Updating all plugin managers to the updates to `AbstractPluginManager`.
72-
- Updating how plugin manager factories work (they're now passed the container
73-
instance in their constructor arguments, as well as any build options).
60+
- [#31](https://github.com/zendframework/zend-mvc/pull/31) and
61+
[#76](https://github.com/zendframework/zend-mvc/pull/76) update the component
62+
to be forwards-compatible with zend-eventmanager v3.
63+
- [#36](https://github.com/zendframework/zend-mvc/pull/36) and
64+
[#76](https://github.com/zendframework/zend-mvc/pull/76) update the component
65+
to be forwards-compatible with zend-servicemanager v3. Several changes were
66+
introduced to support this effort:
7467
- Added a `RouteInvokableFactory`, which can act as either a
75-
`FactoryInterface` or `AbstractFactoryInterface` for loading invokable route
76-
classes, including by fully qualified class name. This is registered as an
77-
abstract factory by default with the `RoutePluginManager`.
68+
`FactoryInterface` or `AbstractFactoryInterface` for loading invokable route
69+
classes, including by fully qualified class name. This is registered as an
70+
abstract factory by default with the `RoutePluginManager`.
7871
- The `DispatchListener` now receives the controller manager instance at
7972
instantiation.
8073
- The `ViewManager` implementations were updated, and most functionality
81-
within separated into discrete factories. (Previously these instances
82-
injected services and aliases into the service manager instance, which is no
83-
longer possible or desirable with the zend-servicemanager v3 changes.)
84-
- `Application::init()` now pulls the configured service manager from the
85-
`Zend\ModuleManager\Listener\ServiceListener` instance before retrieving and
86-
bootstrapping the `Application` instance; this ensure it is fully
87-
configured at that time.
88-
- [#38](https://github.com/zendframework/zend-mvc/pull/38) Ensure middleware
89-
tests against abstract factories
90-
- zend-servicemanager v3 modified the behavior of has() to not search abstract
91-
factories by default. You can force it to do so by passing an optional
92-
second argument, a boolean flag, with a value of boolean true.
74+
within separated into discrete factories.
9375

9476
## 2.6.4 - TBD
9577

composer.json

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414
},
1515
"require": {
1616
"php": "^5.5 || ^7.0",
17-
"zendframework/zend-eventmanager": "dev-develop as 2.7.0",
18-
"zendframework/zend-servicemanager": "dev-develop as 2.6.0",
19-
"zendframework/zend-hydrator": "~1.0",
20-
"zendframework/zend-form": "~2.6",
21-
"zendframework/zend-stdlib": "^2.7.5",
17+
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
18+
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
19+
"zendframework/zend-hydrator": "^1.1 || ^2.1",
20+
"zendframework/zend-form": "^2.7",
21+
"zendframework/zend-stdlib": "^2.7.5 || ^3.0",
2222
"zendframework/zend-psr7bridge": "^0.2",
2323
"container-interop/container-interop": "^1.1"
2424
},
2525
"require-dev": {
26-
"zendframework/zend-authentication": "~2.5",
27-
"zendframework/zend-cache": "~2.5",
28-
"zendframework/zend-console": "~2.5",
29-
"zendframework/zend-di": "~2.5",
30-
"zendframework/zend-filter": "~2.5",
31-
"zendframework/zend-http": "~2.5",
32-
"zendframework/zend-i18n": "~2.5",
33-
"zendframework/zend-inputfilter": "~2.5",
34-
"zendframework/zend-json": "~2.5",
35-
"zendframework/zend-log": "~2.5",
36-
"zendframework/zend-modulemanager": "dev-develop as 2.7.0",
37-
"zendframework/zend-session": "~2.5",
38-
"zendframework/zend-serializer": "~2.5",
39-
"zendframework/zend-text": "~2.5",
40-
"zendframework/zend-uri": "~2.5",
41-
"zendframework/zend-validator": "~2.5",
42-
"zendframework/zend-version": "~2.5",
43-
"zendframework/zend-view": "dev-develop as 2.6.0",
26+
"zendframework/zend-authentication": "^2.5.3",
27+
"zendframework/zend-cache": "^2.6.1",
28+
"zendframework/zend-console": "^2.6",
29+
"zendframework/zend-di": "^2.6",
30+
"zendframework/zend-filter": "^2.6.1",
31+
"zendframework/zend-http": "^2.5.4",
32+
"zendframework/zend-i18n": "^2.6",
33+
"zendframework/zend-inputfilter": "^2.6",
34+
"zendframework/zend-json": "^2.6.1",
35+
"zendframework/zend-log": "^2.7.1",
36+
"zendframework/zend-modulemanager": "^2.7.1",
37+
"zendframework/zend-session": "^2.6.2",
38+
"zendframework/zend-serializer": "^2.6.1",
39+
"zendframework/zend-text": "^2.6",
40+
"zendframework/zend-uri": "^2.5",
41+
"zendframework/zend-validator": "^2.6",
42+
"zendframework/zend-version": "^2.5",
43+
"zendframework/zend-view": "^2.6.3",
4444
"fabpot/php-cs-fixer": "1.7.*",
4545
"phpunit/PHPUnit": "~4.0"
4646
},
@@ -64,12 +64,10 @@
6464
"zendframework/zend-version": "Zend\\Version component",
6565
"zendframework/zend-view": "Zend\\View component"
6666
},
67-
"minimum-stability": "dev",
68-
"prefer-stable": true,
6967
"extra": {
7068
"branch-alias": {
7169
"dev-master": "2.6-dev",
72-
"dev-develop": "3.0-dev"
70+
"dev-develop": "2.7-dev"
7371
}
7472
},
7573
"autoload-dev": {

src/Application.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,22 @@ class Application implements
106106
*
107107
* @param mixed $configuration
108108
* @param ServiceManager $serviceManager
109+
* @param null|EventManagerInterface $events
110+
* @param null|RequestInterface $request
111+
* @param null|ResponseInterface $response
109112
*/
110113
public function __construct(
111114
$configuration,
112115
ServiceManager $serviceManager,
113-
EventManagerInterface $events,
114-
RequestInterface $request,
115-
ResponseInterface $response
116+
EventManagerInterface $events = null,
117+
RequestInterface $request = null,
118+
ResponseInterface $response = null
116119
) {
117120
$this->configuration = $configuration;
118121
$this->serviceManager = $serviceManager;
119-
$this->setEventManager($events);
120-
$this->request = $request;
121-
$this->response = $response;
122+
$this->setEventManager($events ?: $serviceManager->get('EventManager'));
123+
$this->request = $request ?: $serviceManager->get('Request');
124+
$this->response = $response ?: $serviceManager->get('Response');
122125
}
123126

124127
/**
@@ -143,8 +146,8 @@ public function getConfig()
143146
*/
144147
public function bootstrap(array $listeners = [])
145148
{
146-
$events = $this->events;
147149
$serviceManager = $this->serviceManager;
150+
$events = $this->events;
148151

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

264-
$serviceManager = new ServiceManager($smConfig->toArray());
265-
$serviceManager = $serviceManager->withConfig(['services' => [
266-
'ApplicationConfig' => $configuration,
267-
]]);
267+
$serviceManager = new ServiceManager();
268+
$smConfig->configureServiceManager($serviceManager);
269+
$serviceManager->setService('ApplicationConfig', $configuration);
268270

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

272-
// Get the configured SM if necessary.
273-
if ($serviceManager->has('ServiceListener')) {
274-
$serviceListener = $serviceManager->get('ServiceListener');
275-
$serviceManager = $serviceListener->getConfiguredServiceManager();
276-
}
277-
278274
// Prepare list of listeners to bootstrap
279275
$listenersFromAppConfig = isset($configuration['listeners']) ? $configuration['listeners'] : [];
280276
$config = $serviceManager->get('config');
@@ -319,13 +315,15 @@ public function run()
319315

320316
// Trigger route event
321317
$event->setName(MvcEvent::EVENT_ROUTE);
318+
$event->stopPropagation(false); // Clear before triggering
322319
$result = $events->triggerEventUntil($shortCircuit, $event);
323320
if ($result->stopped()) {
324321
$response = $result->last();
325322
if ($response instanceof ResponseInterface) {
326323
$event->setName(MvcEvent::EVENT_FINISH);
327324
$event->setTarget($this);
328325
$event->setResponse($response);
326+
$event->stopPropagation(false); // Clear before triggering
329327
$events->triggerEvent($event);
330328
$this->response = $response;
331329
return $this;
@@ -338,6 +336,7 @@ public function run()
338336

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

343342
// Complete response
@@ -346,6 +345,7 @@ public function run()
346345
$event->setName(MvcEvent::EVENT_FINISH);
347346
$event->setTarget($this);
348347
$event->setResponse($response);
348+
$event->stopPropagation(false); // Clear before triggering
349349
$events->triggerEvent($event);
350350
$this->response = $response;
351351
return $this;
@@ -380,9 +380,11 @@ protected function completeRequest(MvcEvent $event)
380380
$event->setTarget($this);
381381

382382
$event->setName(MvcEvent::EVENT_RENDER);
383+
$event->stopPropagation(false); // Clear before triggering
383384
$events->triggerEvent($event);
384385

385386
$event->setName(MvcEvent::EVENT_FINISH);
387+
$event->stopPropagation(false); // Clear before triggering
386388
$events->triggerEvent($event);
387389

388390
return $this;

0 commit comments

Comments
 (0)