From 184dad7c86f36935b9009c906c6998ba784ccb2f Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:30:03 +1300 Subject: [PATCH] API Deprecate API that's changing in CMS 6 (#1357) * ENH Avoid using deprecated API * API Deprecate API that's changing in CMS 6 --- code/Model/EditableCustomRule.php | 2 +- code/Model/EditableFormField.php | 4 ++-- code/Model/Recipient/EmailRecipient.php | 2 +- code/Model/Recipient/EmailRecipientCondition.php | 2 +- code/Model/UserDefinedForm.php | 3 ++- tests/php/Form/GridFieldAddClassesButtonTest.php | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/code/Model/EditableCustomRule.php b/code/Model/EditableCustomRule.php index 08fa1b407..f48802327 100644 --- a/code/Model/EditableCustomRule.php +++ b/code/Model/EditableCustomRule.php @@ -119,7 +119,7 @@ protected function getCanCreateContext($args) } // Hack in currently edited page if context is missing if (Controller::has_curr() && Controller::curr() instanceof CMSMain) { - return Controller::curr()->currentPage(); + return Controller::curr()->currentRecord(); } // No page being edited diff --git a/code/Model/EditableFormField.php b/code/Model/EditableFormField.php index 37f438ba3..339675fea 100755 --- a/code/Model/EditableFormField.php +++ b/code/Model/EditableFormField.php @@ -509,7 +509,7 @@ public function canEdit($member = null) // This is to restore User Forms 2.x backwards compatibility. $controller = Controller::curr(); if ($controller && $controller instanceof CMSPageEditController) { - $parent = $controller->getRecord($controller->currentPageID()); + $parent = $controller->getRecord($controller->currentRecordID()); // Only allow this behaviour on pages using UserFormFieldEditorExtension, such // as UserDefinedForm page type. if ($parent && $parent->hasExtension(UserFormFieldEditorExtension::class)) { @@ -572,7 +572,7 @@ protected function getCanCreateContext($args) } // Hack in currently edited page if context is missing if (Controller::has_curr() && Controller::curr() instanceof CMSMain) { - return Controller::curr()->currentPage(); + return Controller::curr()->currentRecord(); } // No page being edited diff --git a/code/Model/Recipient/EmailRecipient.php b/code/Model/Recipient/EmailRecipient.php index 5e456e2a3..d357ec282 100644 --- a/code/Model/Recipient/EmailRecipient.php +++ b/code/Model/Recipient/EmailRecipient.php @@ -416,7 +416,7 @@ protected function getCanCreateContext($args) } // Hack in currently edited page if context is missing if (Controller::has_curr() && Controller::curr() instanceof CMSMain) { - return Controller::curr()->currentPage(); + return Controller::curr()->currentRecord(); } // No page being edited diff --git a/code/Model/Recipient/EmailRecipientCondition.php b/code/Model/Recipient/EmailRecipientCondition.php index 760baf453..48b882cbe 100644 --- a/code/Model/Recipient/EmailRecipientCondition.php +++ b/code/Model/Recipient/EmailRecipientCondition.php @@ -143,7 +143,7 @@ protected function getCanCreateContext($args) } // Hack in currently edited page if context is missing if (Controller::has_curr() && Controller::curr() instanceof CMSMain) { - return Controller::curr()->currentPage(); + return Controller::curr()->currentRecord(); } // No page being edited diff --git a/code/Model/UserDefinedForm.php b/code/Model/UserDefinedForm.php index e4c6ec8fb..4c78364f3 100755 --- a/code/Model/UserDefinedForm.php +++ b/code/Model/UserDefinedForm.php @@ -18,12 +18,13 @@ class UserDefinedForm extends Page /** * @var string + * @deprecated 6.4.0 Will be renamed to cms_icon_class */ private static $icon_class = 'font-icon-p-list'; /** * @var string - * @deprecated 5.4.0 use class_description instead. + * @deprecated 6.4.0 use class_description instead. */ private static $description = 'Adds a customizable form.'; diff --git a/tests/php/Form/GridFieldAddClassesButtonTest.php b/tests/php/Form/GridFieldAddClassesButtonTest.php index df96672b2..bed6d7b8d 100644 --- a/tests/php/Form/GridFieldAddClassesButtonTest.php +++ b/tests/php/Form/GridFieldAddClassesButtonTest.php @@ -31,7 +31,7 @@ public function testHandleAddUpdatesModifiedFormData() $request = new HTTPRequest('GET', '/'); $request->setSession(new Session([])); $controller->setRequest($request); - $controller->setCurrentPageID($udf->ID); + $controller->setCurrentRecordID($udf->ID); $controller->pushCurrent(); $list = new DataList(EditableFormField::class); $field = EditableTextField::create([