File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 4242* ``QueryExpression::or_() `` and ``QueryExpression::and_() `` have been
4343 deprecated. Use ``or() `` and ``and() `` instead.
4444
45+ Routing
46+ -------
47+
48+ * ``Cake\Routing\Exception\RedirectException `` is deprecated. Use
49+ ``Cake\Http\Exception\RedirectException `` instead.
50+
4551View
4652----
4753
7076
7177* BelongsToMany associations now respect the bindingKey set in the junction table's BelongsTo association.
7278 Previously, the target table's primary key was always used instead.
73-
79+
7480TestSuite
7581---------
7682
@@ -113,6 +119,17 @@ Error
113119 respectively.
114120* The ``Debugger.editor `` configure value has been added. This value is used as
115121 the preferred editor link format.
122+ * ``ErrorHandlerMiddleware `` now handles
123+ ``Http\Exception\RedirectException `` and converts those exceptions into HTTP
124+ redirect responses.
125+
126+ Http
127+ ----
128+
129+ * ``Cake\Http\Exception\RedirectException `` was added. This exception replaces
130+ the ``RedirectException `` in the Routing package and can be raised anywhere in
131+ your application to signal to the error handling middleware to create
132+ a redirect response.
116133
117134Log
118135---
Original file line number Diff line number Diff line change @@ -321,7 +321,26 @@ To redirect from within a component callback method you can use the following::
321321
322322By stopping the event you let CakePHP know that you don't want any other
323323component callbacks to run, and that the controller should not handle the action
324- any further.
324+ any further. As of 4.1.0 you can raise a ``RedirectException `` to signal
325+ a redirect::
326+
327+ use Cake\Http\Exception\RedirectException;
328+ use Cake\Routing\Router;
329+
330+ public function beforeFilter(EventInterface $event)
331+ {
332+ throw new RedirectException(Router::url('/'))
333+ }
334+
335+ Raising an exception will halt all other event listeners and create a new
336+ response that doesn't retain or inherit any of the current response's headers.
337+ When raising a ``RedirectException `` you can include additional headers::
338+
339+ throw new RedirectException(Router::url('/'), 302, [
340+ 'Header-Key' => 'value',
341+ ]);
342+
343+ .. versionadded :: 4.1.0
325344
326345.. meta ::
327346 :title lang=en: Components
You can’t perform that action at this time.
0 commit comments