-
Notifications
You must be signed in to change notification settings - Fork 196
Mark deprecated functionality #429
Changes from all commits
802c4f9
dde9a68
ccf2346
714b61a
aa5d2ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,6 +335,13 @@ public function pipe($path, $middleware = null) | |
* Once middleware detection and wrapping (if necessary) is complete, | ||
* proxies to pipe(). | ||
* | ||
* @deprecated since 1.1.0; to remove in 2.0.0. Stratigility v1-style | ||
* "error middleware" (middleware with four arguments, the first of which | ||
* being an error) was deprecated in Stratigility 1.3, and support | ||
* removed in Stratigility 2.0. You can start using standard middleware | ||
* for error handling by calling `raiseThrowables()` on the `Application` | ||
* instance, and piping such middleware in an outer layer of your application. | ||
* For an example, see `Zend\Stratigility\Middleware\ErrorHandler`. | ||
* @param string|callable $path Either a URI path prefix, or middleware. | ||
* @param null|string|callable $middleware Middleware | ||
* @return self | ||
|
@@ -410,6 +417,11 @@ public function pipeRouteResultObserverMiddleware() | |
* Allow header, and `$next()` is called with its `$error` argument set | ||
* to the value `405` (invoking the next error middleware). | ||
* | ||
* @deprecated since 1.1.0; to remove in 2.0.0. This method is extracted to | ||
* its own dedicated middleware class starting in 2.0.0. If you are | ||
* manually piping this method into your application or middleware | ||
* pipelines, or overriding the method, you will need to update your | ||
* code when migrating to 2.0. | ||
* @param ServerRequestInterface $request | ||
* @param ResponseInterface $response | ||
* @param callable $next | ||
|
@@ -453,6 +465,11 @@ public function routeMiddleware(ServerRequestInterface $request, ResponseInterfa | |
* Finally, it attempts to marshal the middleware, and dispatches it when | ||
* complete, return the response. | ||
* | ||
* @deprecated since 1.1.0; to remove in 2.0.0. This method is extracted to | ||
* its own dedicated middleware class starting in 2.0.0. If you are | ||
* manually piping this method into your application or middleware | ||
* pipelines, or overriding the method, you will need to update your | ||
* code when migrating to 2.0. | ||
* @param ServerRequestInterface $request | ||
* @param ResponseInterface $response | ||
* @param callable $next | ||
|
@@ -598,6 +615,9 @@ public function getContainer() | |
/** | ||
* Return the final handler to use during `run()` if the stack is exhausted. | ||
* | ||
* @deprecated since 1.1.0; renamed to `getDefaultDelegate()` in version | ||
* 2.0.0. If you are consuming this method, please update your code to call | ||
* getDefaultDelegate() instead. | ||
* @param null|ResponseInterface $response Response instance with which to seed the | ||
* FinalHandler; used to determine if the response passed to the handler | ||
* represents the original or final response state. | ||
|
@@ -618,6 +638,20 @@ public function getFinalHandler(ResponseInterface $response = null) | |
return $this->finalHandler; | ||
} | ||
|
||
/** | ||
* Return the default delegate to use during `run()` when the stack is exhausted. | ||
* | ||
* Provided as a forwards compatibility measure with version 2, and proxies | ||
* to getFinalHandler(); please note that it does not accept any arguments, | ||
* nor pass them on to that method. | ||
* | ||
* @return callable|null | ||
*/ | ||
public function getDefaultDelegate() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to expose a getter for final handler after all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's used internally to lazy-load it when required and none was injected during instantiation, which makes it a canonical source for locating it if the service is not defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, but it does not need to be public, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, it becomes the canonical source for the service if no service is registered in the container. As such, if you need access to it for any reason (e.g., to re-use it elsewhere), it would need to be public. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mhmm, sorry but it's not clear to me why would someone want to re-use it outside of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure: you could be nesting an application within another, and want to re-use the default delegate from the parent application. As such, you might build the factory like this: use Zend\Expressive\AppFactory;
use Zend\Expressive\Application;
use Zend\Expressive\Router\FastRouteRouter;
function ($container)
{
$app = $container->get(Application::class);
$nested = new Application(
new FastRouteRouter(),
$container,
$app->getDefaultDelegate()
);
/* pipe and/or route some middleware */
$nested->pipe(/* ... */);
$nested->get('/subpath', /* ... */);
return $nested;
} In normal circumstances, if this were dispatched, if a call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haa, thanks for clarifying! These fallback services would be a lot easier if Expressive could provide its default container config that people could override, but unfortunately it would not work with all container interop implementations. 😕 |
||
{ | ||
return $this->getFinalHandler(); | ||
} | ||
|
||
/** | ||
* Retrieve an emitter to use during run(). | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{@see Zend\Stratigility\Middleware\ErrorHandler}
?