From 7d9f34bf1a412c0503281743f38767fd7b01c3d7 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 21 Jan 2022 11:23:23 +1300 Subject: [PATCH] Use api for entityRole - addresses save issue on the form --- CRM/ACL/BAO/EntityRole.php | 2 ++ CRM/ACL/Form/EntityRole.php | 10 +++++++--- CRM/ACL/Page/EntityRole.php | 2 +- CRM/Admin/Page/AJAX.php | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CRM/ACL/BAO/EntityRole.php b/CRM/ACL/BAO/EntityRole.php index 8a72c8006c..3bacbf7639 100644 --- a/CRM/ACL/BAO/EntityRole.php +++ b/CRM/ACL/BAO/EntityRole.php @@ -17,5 +17,7 @@ /** * Access Control EntityRole. + * + * @deprecated */ class CRM_ACL_BAO_EntityRole extends CRM_ACL_BAO_ACLEntityRole {} diff --git a/CRM/ACL/Form/EntityRole.php b/CRM/ACL/Form/EntityRole.php index eaed454de8..7eb6b667b0 100644 --- a/CRM/ACL/Form/EntityRole.php +++ b/CRM/ACL/Form/EntityRole.php @@ -9,6 +9,8 @@ +--------------------------------------------------------------------+ */ +use Civi\Api4\ACLEntityRole; + /** * * @package CRM @@ -44,12 +46,14 @@ class CRM_ACL_Form_EntityRole extends CRM_Admin_Form { /** * Process the form submission. + * + * @throws \API_Exception */ - public function postProcess() { + public function postProcess(): void { CRM_ACL_BAO_Cache::resetCache(); if ($this->_action & CRM_Core_Action::DELETE) { - CRM_ACL_BAO_EntityRole::del($this->_id); + ACLEntityRole::delete()->addWhere('id', '=', $this->_id)->execute(); CRM_Core_Session::setStatus(ts('Selected Entity Role has been deleted.'), ts('Record Deleted'), 'success'); } else { @@ -59,7 +63,7 @@ class CRM_ACL_Form_EntityRole extends CRM_Admin_Form { } $params['entity_table'] = 'civicrm_group'; - CRM_ACL_BAO_EntityRole::create($params); + AclEntityRole::save()->setRecords([$params])->execute(); } } diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 3eea492223..f52ac442e4 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -32,7 +32,7 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { * Classname of BAO. */ public function getBAOName() { - return 'CRM_ACL_BAO_EntityRole'; + return 'CRM_ACL_BAO_ACLEntityRole'; } /** diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index d47b9caf05..e300e60add 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -224,7 +224,7 @@ class CRM_Admin_Page_AJAX { $ret['content'] = ts('Are you sure you want to disable this ACL?'); break; - case 'CRM_ACL_BAO_EntityRole': + case 'CRM_ACL_BAO_ACLEntityRole': $ret['content'] = ts('Are you sure you want to disable this ACL Role Assignment?'); break; -- 2.25.1