/**
* Class CRM_Mailing_BAO_Mailing
*/
-class CRM_Mailing_BAO_Mailing extends CRM_Mailing_DAO_Mailing {
+class CRM_Mailing_BAO_Mailing extends CRM_Mailing_DAO_Mailing implements \Civi\Core\HookInterface {
/**
* An array that holds the complete templates
* Id of the mail to delete.
*
* @return void
+ *
+ * @deprecated
*/
public static function del($id) {
- if (empty($id)) {
- throw new CRM_Core_Exception(ts('No id passed to mailing del function'));
- }
-
- CRM_Utils_Hook::pre('delete', 'Mailing', $id);
-
- // delete all file attachments
- CRM_Core_BAO_File::deleteEntityFile('civicrm_mailing',
- $id
- );
-
- $dao = new CRM_Mailing_DAO_Mailing();
- $dao->id = $id;
- $dao->delete();
-
- CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'), ts('Deleted'), 'success');
+ static::deleteRecord(['id' => $id]);
+ }
- CRM_Utils_Hook::post('delete', 'Mailing', $id, $dao);
+ /**
+ * Callback for hook_civicrm_pre().
+ * @param \Civi\Core\Event\PreEvent $event
+ * @throws CRM_Core_Exception
+ */
+ public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) {
+ if ($event->action === 'delete' && $event->id) {
+ // Delete all file attachments
+ CRM_Core_BAO_File::deleteEntityFile('civicrm_mailing', $event->id);
+ }
}
/**
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Mailing_BAO_Mailing::del($this->_mailingId);
+ CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'), ts('Deleted'), 'success');
}
elseif ($this->_action & CRM_Core_Action::DISABLE) {
CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);