[REF] Cleanup BAO_ActionSchedule::getlist() signature
authoreileen <emcnaughton@wikimedia.org>
Thu, 6 May 2021 02:19:08 +0000 (14:19 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 6 May 2021 02:21:11 +0000 (14:21 +1200)
This is only called from 3 places. Only one passes variables.

Of the 3 2 check if the results is an array - civirules does not
(civirules doesn't really use this function - it would be better to
do a v4 api get)

CRM/Admin/Page/ScheduleReminders.php
CRM/Core/BAO/ActionSchedule.php
CRM/Event/Form/ManageEvent/ScheduleReminders.php

index 524031760ea710e3e1738a9cda55a41b998c88fa..2eb555d1753750684eb88cab6b59be7ccb73b841 100644 (file)
@@ -126,27 +126,25 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic {
     // Get list of configured reminders
     $reminderList = CRM_Core_BAO_ActionSchedule::getList();
 
-    if (is_array($reminderList)) {
-      // Add action links to each of the reminders
-      foreach ($reminderList as & $format) {
-        $action = array_sum(array_keys($this->links()));
-        if ($format['is_active']) {
-          $action -= CRM_Core_Action::ENABLE;
-        }
-        else {
-          $action -= CRM_Core_Action::DISABLE;
-        }
-        $format['action'] = CRM_Core_Action::formLink(
-          self::links(),
-          $action,
-          ['id' => $format['id']],
-          ts('more'),
-          FALSE,
-          'actionSchedule.manage.action',
-          'ActionSchedule',
-          $format['id']
-        );
+    // Add action links to each of the reminders
+    foreach ($reminderList as & $format) {
+      $action = array_sum(array_keys($this->links()));
+      if ($format['is_active']) {
+        $action -= CRM_Core_Action::ENABLE;
       }
+      else {
+        $action -= CRM_Core_Action::DISABLE;
+      }
+      $format['action'] = CRM_Core_Action::formLink(
+        self::links(),
+        $action,
+        ['id' => $format['id']],
+        ts('more'),
+        FALSE,
+        'actionSchedule.manage.action',
+        'ActionSchedule',
+        $format['id']
+      );
     }
 
     $this->assign('rows', $reminderList);
index b57abb0a2cacb90ab076a416541444734ec9dd87..b2f4d1770a7144a9f3523a647b46f23ee44c6d94 100644 (file)
@@ -102,9 +102,6 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule {
   /**
    * Retrieve list of Scheduled Reminders.
    *
-   * @param bool $namesOnly
-   *   Return simple list of names.
-   *
    * @param \Civi\ActionSchedule\Mapping|null $filterMapping
    *   Filter by the schedule's mapping type.
    * @param int $filterValue
@@ -114,7 +111,8 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule {
    *   (reference)   reminder list
    * @throws \CRM_Core_Exception
    */
-  public static function &getList($namesOnly = FALSE, $filterMapping = NULL, $filterValue = NULL) {
+  public static function getList($filterMapping = NULL, $filterValue = NULL): array {
+    $list = [];
     $query = "
 SELECT
        title,
index 36b4619f513f55e0e221af7c9df00535935e3e0f..7e1144afc271cc2ddbdb2e05e89ee031bc4a40df 100644 (file)
@@ -35,32 +35,30 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage
     $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([
       'id' => ($this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID),
     ]));
-    $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id);
-    if ($reminderList && is_array($reminderList)) {
-      // Add action links to each of the reminders
-      foreach ($reminderList as & $format) {
-        $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
-        if ($format['is_active']) {
-          $action += CRM_Core_Action::DISABLE;
-        }
-        else {
-          $action += CRM_Core_Action::ENABLE;
-        }
-        $scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
-        $links = $scheduleReminder->links();
-        $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
-        $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
-        $format['action'] = CRM_Core_Action::formLink(
-          $links,
-          $action,
-          ['id' => $format['id']],
-          ts('more'),
-          FALSE,
-          'actionSchedule.manage.action',
-          'ActionSchedule',
-          $this->_id
-        );
+    $reminderList = CRM_Core_BAO_ActionSchedule::getList($mapping, $this->_id);
+    // Add action links to each of the reminders
+    foreach ($reminderList as & $format) {
+      $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
+      if ($format['is_active']) {
+        $action += CRM_Core_Action::DISABLE;
       }
+      else {
+        $action += CRM_Core_Action::ENABLE;
+      }
+      $scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
+      $links = $scheduleReminder->links();
+      $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
+      $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
+      $format['action'] = CRM_Core_Action::formLink(
+        $links,
+        $action,
+        ['id' => $format['id']],
+        ts('more'),
+        FALSE,
+        'actionSchedule.manage.action',
+        'ActionSchedule',
+        $this->_id
+      );
     }
 
     $this->assign('rows', $reminderList);