diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 5bb34367c713..f811d03793a0 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -630,6 +630,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 e4c7b71dcac3..189aa37c2ebc 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 *