copyValues($params); $widget->save(); return $widget; } /** * 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_Widget objects */ static function retrieve(array $params) { $result = array(); $widget = new CRM_Wci_BAO_Widget(); $widget->copyValues($params); $widget->find(); while ($widget->fetch()) { $result[(int) $widget->id] = clone $widget; } $widget->free(); return $result; } /** * Wrapper method for retrieve * * @param mixed $id Int or int-like string representing widget ID * @return CRM_Wci_BAO_Widget */ static function retrieveByID($id) { if (!is_int($id) && !ctype_digit($id)) { CRM_Core_Error::fatal(__CLASS__ . '::' . __FUNCTION__ . ' expects an integer.'); } $id = (int) $id; $widgets = self::retrieve(array('id' => $id)); if (!array_key_exists($id, $widgets)) { CRM_Core_Error::fatal("No widget with ID $id exists."); } return $widgets[$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('title', $params)) { return TRUE; } return FALSE; } }