Skip to content

Commit

Permalink
Add documentation for cakephp/cakephp#18015
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 11, 2024
1 parent 23b65f8 commit bb77820
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions en/appendices/5-2-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Behavior Changes
overwritten by accident.
- ``Http\Session`` will now raise an exception when an invalid session preset is
used.
- ``FormProtectionComponent`` now raises ``Cake\Controller\Exception\FormProtectionException``. This
class is a subclass of ``BadRequestException``, and offers the benefit of
being filterable from logging.

New Features
============
Expand Down
5 changes: 4 additions & 1 deletion en/controllers/components/form-protection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@ configuration option to a callback function in the controller.
By configuring a callback method you can customize how the failure handling process
works::

use Cake\Controller\Exception\FormProtectionException;

public function beforeFilter(EventInterface $event)
{
parent::beforeFilter($event);

$this->FormProtection->setConfig(
'validationFailureCallback',
function (BadRequestException $exception) {
// Prior to 5.2 use Cake\Http\Exception\BadRequestException.
function (FormProtectionException $exception) {
// You can either return a response instance or throw the exception
// received as argument.
}
Expand Down

0 comments on commit bb77820

Please sign in to comment.