You are here

public function ActivityNotifications::deleteNotificationsbyIds in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::deleteNotificationsbyIds()
  2. 10.3.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::deleteNotificationsbyIds()
  3. 10.0.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::deleteNotificationsbyIds()
  4. 10.1.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::deleteNotificationsbyIds()
  5. 10.2.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::deleteNotificationsbyIds()

Deletes all entries in activity_notification_table by given ids.

Parameters

array $activity_ids: Array of activity ids to be deleted.

Return value

bool Status of update query.

File

modules/custom/activity_creator/src/ActivityNotifications.php, line 254

Class

ActivityNotifications
Class ActivityNotifications to get Personalised activity items for account.

Namespace

Drupal\activity_creator

Code

public function deleteNotificationsbyIds(array $activity_ids) : bool {
  if (!empty($activity_ids)) {

    // The transaction opens here.
    $txn = $this->database
      ->startTransaction();
    try {
      $this->database
        ->delete('activity_notification_status')
        ->condition('aid', $activity_ids, 'IN')
        ->execute();
    } catch (\Exception $exception) {

      // Something went wrong somewhere, so roll back now.
      $txn
        ->rollBack();

      // Log the exception to watchdog.
      $this
        ->getLogger('default')
        ->error($exception
        ->getMessage());
    }
    return TRUE;
  }
  return FALSE;
}