diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 617c91f2a491..6e1d3c205c84 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -616,6 +616,10 @@ public function table() { */ public function save($hook = TRUE) { $eventID = uniqid(); + if ($hook) { + CRM_Utils_Hook::preSave($this); + } + if (!empty($this->id)) { if ($hook) { $preEvent = new \Civi\Core\DAO\Event\PreUpdate($this); diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 82877f3feb08..46029ecaa198 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1575,6 +1575,19 @@ public static function alterAPIPermissions($entity, $action, &$params, &$permiss ); } + /** + * @param CRM_Core_DAO $dao + * + * @return mixed + */ + public static function preSave(&$dao) { + $hookName = 'civicrm_preSave_' . $dao->getTableName(); + return self::singleton()->invoke(array('dao'), $dao, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + $hookName + ); + } + /** * @param CRM_Core_DAO $dao *