There is nothing in the documentation about stopping events when used with redirects.
Here (Controllers) we find a link to stopping events:
https://book.cakephp.org/5/en/controllers.html#controller-callback-methods
Which then leads to this section:
https://book.cakephp.org/5/en/core-libraries/events.html#stopping-events
Moreover, I found this (Components):
https://book.cakephp.org/5/en/controllers/components.html#using-redirects-in-component-events
So actually there is something, but it is probably (?) an obsolete example and described in relation to the components only.
Even in the upper section, there is probably something obsolete (see description for beforeRedirect, where it says it can return false)
In my opinion, instead, something like this should be documented:
public function beforeFilter(EventInterface $event): void
{
if ($needsStopAndRedirect) {
$event->stopPropagation();
$this->redirect('/');
return;
}
//This code should be executed only if `$needsStopAndRedirect` is false
// ...
}
Also because I'm not sure that this is the correct procedure either.
There is nothing in the documentation about stopping events when used with redirects.
Here (Controllers) we find a link to stopping events:
https://book.cakephp.org/5/en/controllers.html#controller-callback-methods
Which then leads to this section:
https://book.cakephp.org/5/en/core-libraries/events.html#stopping-events
Moreover, I found this (Components):
https://book.cakephp.org/5/en/controllers/components.html#using-redirects-in-component-events
So actually there is something, but it is probably (?) an obsolete example and described in relation to the components only.
Even in the upper section, there is probably something obsolete (see description for
beforeRedirect, where it says it can returnfalse)In my opinion, instead, something like this should be documented:
Also because I'm not sure that this is the correct procedure either.