From 317ac11e70b80fa9c8034c46148a88c770f0cdc5 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Jan 2024 15:14:19 +1300 Subject: [PATCH] Minor cleanup in ReportInstance BAO --- CRM/Report/BAO/ReportInstance.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index f062d57310..12717ed113 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -9,6 +9,8 @@ +--------------------------------------------------------------------+ */ +use Civi\Core\Event\PreEvent; + /** * * @package CRM @@ -44,18 +46,15 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implem } /** - * Create instance. - * - * takes an associative array and creates a instance object and does any related work like permissioning, adding to dashboard etc. + * Create report instance. * - * This function is invoked from within the web form layer and also from the api layer + * Does any related work like creating navigation, adding to dashboard etc. * * @param array $params - * (reference ) an assoc array of name/value pairs. * * @return CRM_Report_DAO_ReportInstance */ - public static function &create(&$params) { + public static function create(array $params) { // Transform nonstandard field names used by quickform $params['id'] ??= ($params['instance_id'] ?? NULL); if (isset($params['report_header'])) { @@ -112,10 +111,6 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implem $transaction = new CRM_Core_Transaction(); $instance = self::add($params); - if (is_a($instance, 'CRM_Core_Error')) { - $transaction->rollback(); - return $instance; - } // add / update navigation as required if (!empty($navigationParams)) { @@ -177,9 +172,12 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implem /** * Event fired prior to modifying a ReportInstance. + * * @param \Civi\Core\Event\PreEvent $event + * + * @throws \CRM_Core_Exception */ - public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) { + public static function self_hook_civicrm_pre(PreEvent $event): void { if ($event->action === 'delete' && $event->id) { // When deleting a report, also delete from navigation menu $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $event->id, 'navigation_id'); -- 2.25.1