From 2df7edac12f65b4824ca857c9af2f1a98a4d6bb7 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 24 Nov 2025 13:50:19 +0530 Subject: [PATCH 1/2] Add info about EventManagerInterface::on() signature change. Refs cakephp/cakephp#19068 --- en/appendices/6-0-migration-guide.rst | 7 +++++++ en/core-libraries/events.rst | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/en/appendices/6-0-migration-guide.rst b/en/appendices/6-0-migration-guide.rst index 3e9282a418..610a7ce99f 100644 --- a/en/appendices/6-0-migration-guide.rst +++ b/en/appendices/6-0-migration-guide.rst @@ -72,6 +72,13 @@ Some methods have also been renamed to better reflect their purpose. These are: * ``Cake\View\Helper\PaginatorHelper`` - ``_numbers()`` has been renamed to ``buildNumbers()`` +Event +----- + +- The signature of ``EventManagerInterface::on()`` has changed. The 2nd and 3rd + parameters have been swapped. Calls which pass an options array as the 2nd + argument will need to be updated to pass it as the 3rd argument instead. + Datasource ---------- diff --git a/en/core-libraries/events.rst b/en/core-libraries/events.rst index 8af328fac1..7baba6036e 100644 --- a/en/core-libraries/events.rst +++ b/en/core-libraries/events.rst @@ -412,8 +412,8 @@ for event listeners:: $callback = [$this, 'doSomething']; $this->getEventManager()->on( 'Order.afterPlace', - ['priority' => 2], $callback + ['priority' => 2], ); // Setting priority for a listener From c3b98d5d1435d38229f0ea3b28e75e36ede27d46 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 25 Nov 2025 10:19:33 +0530 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: othercorey --- en/appendices/6-0-migration-guide.rst | 3 ++- en/core-libraries/events.rst | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/en/appendices/6-0-migration-guide.rst b/en/appendices/6-0-migration-guide.rst index 610a7ce99f..f708b7104f 100644 --- a/en/appendices/6-0-migration-guide.rst +++ b/en/appendices/6-0-migration-guide.rst @@ -77,7 +77,8 @@ Event - The signature of ``EventManagerInterface::on()`` has changed. The 2nd and 3rd parameters have been swapped. Calls which pass an options array as the 2nd - argument will need to be updated to pass it as the 3rd argument instead. + argument will need to be updated to pass it as the 3rd argument instead or + use named parameters. Datasource ---------- diff --git a/en/core-libraries/events.rst b/en/core-libraries/events.rst index 7baba6036e..26bf6cd1d2 100644 --- a/en/core-libraries/events.rst +++ b/en/core-libraries/events.rst @@ -412,7 +412,7 @@ for event listeners:: $callback = [$this, 'doSomething']; $this->getEventManager()->on( 'Order.afterPlace', - $callback + $callback, ['priority' => 2], );