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

Commit 3c097f7

Browse files
committed
Added documentation for #139 in migration doc
1 parent 9b7ae02 commit 3c097f7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: doc/book/migration/to-v3-0.md

+29
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,35 @@ $ composer require zendframework/zend-validator
410410
Note: the above assumes you have already installed zend-component-installer, per
411411
the section above on [dependency reduction](#dependency-reduction).
412412

413+
## Zend\Mvc\View\InjectTemplateListener
414+
415+
The `InjectTemplateListener` attempts to map a controller *service* name to a
416+
template using a variety of heuristics, including an explicit map provided
417+
during configuration, or auto-detection based on the service name.
418+
419+
In version 2, the autodetection took into consideration the `__NAMESPACE__`
420+
provided in routing configuration, and would omit the module subnamespace if a
421+
match was found. This caused issues when multiple modules shared a top-level
422+
namespace (e.g., `ZF\Apigility` and `ZF\Apigility\Admin`) if each had a
423+
controller with the same name.
424+
425+
To avoid naming conflicts, version 3 removes this aspect of autodetection, and
426+
instead provides exactly one workflow for mapping:
427+
428+
- Strip the `Controller` subnamespace, if present (e.g.,
429+
the namespace `Application\Controller\\` is normalized to
430+
`Application\\`).
431+
- Strip the `Controller` suffix in the class name, if present (e.g.,
432+
`IndexController` is normalized to `Index`).
433+
- Inflect CamelCasing to dash-separated (e.g., `ShowUsers` becomes
434+
`show-users`).
435+
- Replace the namespace separator with a slash.
436+
437+
As a full example, the controller service name
438+
`TestSomething\With\Controller\CamelCaseController` will always map to
439+
`test-something/with/camel-case`, regardless of the `__NAMESPACE__` value
440+
provided in routing configuration.
441+
413442
## Zend\Mvc\View\SendResponseListener
414443

415444
`Zend\Mvc\View\SendResponseListener` was deprecated with the 2.2 release, and

0 commit comments

Comments
 (0)