This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As noted in a comment on a zend-expressive issue, the current approach to registering the
UrlHelper
is not feasible, due to the following issues:UrlHelper
is pulled during creation of theTemplateRendererInterface
instance, and aTemplatedErrorHandler
(or derivative, such as the whoops error handler) is also used, a circular dependency occurs. This is due to theUrlHelperFactory
also pulling theApplication
service (as theTemplatedErrorHandler
instance is pulled inside theApplicationFactory
).UrlHelper
creation is delayed until first use (e.g., in zend-expressive-zendviewrenderer'surl
helper factory), the helper is created after route result observers are updated, which means the helper never receives the route result.This patch does the following:
UrlHelperMiddleware
, which composes aUrlHelper
and aRouteResultSubjectInterface
instance; when invoked, it attaches the helper to the subject as an observer.UrlHelperMiddlewareFactory
, which creates aUrlHelperMiddleware
instance, using theUrlHelper
service, and either theRouteResultSubjectInterface
orApplication
service instance.UrlHelperFactory
to no longer pull theApplication
instance and attach the helper to it.The plan is to update zend-expressive-skeleton to auto-register the
UrlHelperMiddleware
as pipeline middleware, just as we have done with theServerUrlMiddleware
.