/** * Function to add or update action * * @param array $params * @return array $result * @access public * @throws Exception when params is empty * @static */ public static function add($params) { $result = array(); if (empty($params)) { throw new Exception('Params can not be empty when adding or updating a civirule action'); } $action = new CRM_Civirules_BAO_Action(); $fields = self::fields(); foreach ($params as $key => $value) { if (isset($fields[$key])) { $action->{$key} = $value; } } $action->save(); self::storeValues($action, $result); return $result; }