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

Commit c342944

Browse files
committed
Provided initial migration docs
These cover the BC breaks created with the current patch.
1 parent 8b7915a commit c342944

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/doc export-ignore
12
/test export-ignore
23
/vendor export-ignore
34
.coveralls.yml export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.*.sw*
77
.*.un~
88
nbproject
9+
doc/html/
910
tmp/
1011

1112
clover.xml

doc/book/migration.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Migration Guide
2+
3+
This is a guide for migration from version 2 to version 3 of zend-mvc.
4+
5+
## Application
6+
7+
The constructor signature of `Zend\Mvc\Application` has changed. Previously, it
8+
was:
9+
10+
```php
11+
__construct($configuration, ServiceManager $serviceManager)
12+
```
13+
14+
and internally, it pulled the services `EventManager`, `Request`, and `Response`
15+
from the provided `$serviceManager` during initialization.
16+
17+
The new constructor signature is:
18+
19+
```php
20+
__construct(
21+
$configuration,
22+
ServiceManager $serviceManager,
23+
EventManager $events,
24+
RequestInterface $request,
25+
ResponseInterface $response
26+
)
27+
```
28+
29+
making all dependencies explicit. The factory
30+
`Zend\Mvc\Service\ApplicationFactory` was updated to follow the new signature.
31+
32+
This change should only affect users who are manually instantiating the
33+
`Application` instance.
34+
35+
## EventManager initializer and ControllerManager event manager injection
36+
37+
zend-mvc provides two mechanisms for injecting event managers into
38+
`EventManagerAware` objects. One is the "EventManagerAwareInitializer"
39+
registered in `Zend\Mvc\Service\ServiceManagerConfig`, and the other is internal
40+
logic in `Zend\Mvc\Controller\ControllerManager`. In both cases, the logic was
41+
updated due to changes in the v3 version of zend-eventmanager.
42+
43+
Previously each would check if the instance's `getEventManager()` method
44+
returned an event manager instance, and, if so, inject the shared event manager:
45+
46+
```php
47+
$events = $instance->getEventManager();
48+
if ($events instanceof EventManagerInterface) {
49+
$events->setSharedManager($container->get('SharedEventManager'));
50+
}
51+
```
52+
53+
In zend-eventmanager v3, event manager's are now injected with the shared
54+
manager at instantiation, and no setter exists for providing the shared manager.
55+
As such, the above logic changed to:
56+
57+
```php
58+
$events = $instance->getEventManager();
59+
if (! $events || ! $events->getSharedManager()) {
60+
$instance->setEventManager($container->get('EventManager'));
61+
}
62+
```
63+
64+
In other words, it re-injects with a new event manager instance if the instance
65+
pulled does not have a shared manager composed.
66+
67+
This likely will not cause regressions in existing code, but may be something to
68+
be aware of if you were previously depending on lazy-loaded event manager
69+
state.

doc/bookdown.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"title": "zend-mvc: MVC application provider",
3+
"content": [
4+
{"Intro": "../README.md"},
5+
{"Migration Guide": "book/migration.md"}
6+
],
7+
"target": "./html"
8+
}

0 commit comments

Comments
 (0)