copyValues($params); $progress_bar_formula->save(); return $progress_bar_formula; } /** * Get a list of Widgets matching the params, where params keys are column * names of civicrm_wci_widget. * * @param array $params * @return array of CRM_Wci_BAO_ProgressBarFormula objects */ static function retrieve(array $params) { $result = array(); $progress_bar_formula = new CRM_Wci_BAO_ProgressBarFormula(); $progress_bar_formula->copyValues($params); $progress_bar_formula->find(); while ($progress_bar_formula->fetch()) { $result[(int) $progress_bar_formula->id] = clone $progress_bar_formula; } $progress_bar_formula->free(); return $result; } /** * Wrapper method for retrieve * * @param mixed $id Int or int-like string representing widget ID * @return CRM_Wci_BAO_ProgressBarFormula */ static function retrieveByID($id) { if (!is_int($id) && !ctype_digit($id)) { CRM_Core_Error::fatal(__CLASS__ . '::' . __FUNCTION__ . ' expects an integer.'); } $id = (int) $id; $progress_bar_formulas = self::retrieve(array('id' => $id)); if (!array_key_exists($id, $progress_bar_formulas)) { CRM_Core_Error::fatal("No formula entry with ID $id exists."); } return $progress_bar_formulas[$id]; } /** * Check if there is absolute minimum of data to add the object * * @param array $params (reference ) an assoc array of name/value pairs * * @return boolean * @access public */ public static function dataExists($params) { if (CRM_Utils_Array::value('contribution_page_id', $params) && CRM_Utils_Array::value('progress_bar_id', $params)) { return TRUE; } return FALSE; } }