You are here

interface UtilsInterface in Webform CiviCRM Integration 8.5

Hierarchy

Expanded class hierarchy of UtilsInterface

All classes that implement UtilsInterface

File

src/UtilsInterface.php, line 7

Namespace

Drupal\webform_civicrm
View source
interface UtilsInterface {

  /**
   * Explodes form key into an array and verifies that it is in the right format
   *
   * @param $key
   *   Webform component field key (string)
   *
   * @return array or NULL
   */
  public function wf_crm_explode_key($key);

  /**
   * Get options for a specific field
   *
   * @param array $field
   *   Webform component array
   * @param string $context
   *   Where is this being called from?
   * @param array $data
   *   Array of crm entity data
   *
   * @return array
   */
  public static function wf_crm_field_options($field, $context, $data);

  /**
   * Fetches CiviCRM field data.
   *
   * @param string $var
   *   Name of variable to return: fields, tokens, or sets
   *
   * @return array
   * @return array
   *   fields: The CiviCRM contact fields this module supports
   *   tokens: Available tokens keyed to field ids
   *   sets: Info on fieldsets (entities)
   */
  public function wf_crm_get_fields($var = 'fields');

  /**
   * Get list of states, keyed by abbreviation rather than ID.
   * @param null|int|string $param
   */
  public function wf_crm_get_states($param = NULL);

  /**
   * Match a state/province id to its abbr. and vice-versa
   *
   * @param $input
   *   User input (state province id or abbr)
   * @param $ret
   *   String: 'abbreviation' or 'id'
   * @param $country_id
   *   Int: (optional) must be supplied if fetching id from abbr
   *
   * @return string or integer
   */
  function wf_crm_state_abbr($input, $ret = 'abbreviation', $country_id = NULL);

  /**
   * Get list of events.
   *
   * @param array $reg_options
   * @param string $context
   *
   * @return array
   */
  function wf_crm_get_events($reg_options, $context);

  /**
   * @param array $event
   * @param string $format
   * @return string
   */
  function wf_crm_format_event($event, $format);

  /**
   * Fetch tags within a given tagset
   *
   * If no tagset specified, all tags NOT within a tagset are returned.
   * Return format is a flat array with some tic marks to indicate nesting.
   *
   * @param string $used_for
   * @param int $parent_id
   * @return array
   */
  function wf_crm_get_tags($used_for, $parent_id = NULL);

  /**
   * Get list of surveys
   * @param array $act
   *
   * @return array
   */
  function wf_crm_get_surveys($act = []);

  /**
   * Get activity types related to CiviCampaign
   * @return array
   */
  function wf_crm_get_campaign_activity_types();

  /**
   * Get contact types and sub-types
   * Unlike pretty much every other option list CiviCRM wants "name" instead of "id"
   *
   * @return array
   */
  function wf_crm_get_contact_types();

  /**
   * In reality there is no contact field 'privacy' so this is not a real option list.
   * These are actually 5 separate contact fields that this module munges into 1 for better usability.
   *
   * @return array
   */
  function wf_crm_get_privacy_options();

  /**
   * Get relationship type data
   *
   * @return array
   */
  function wf_crm_get_relationship_types();

  /**
   * Get valid relationship types for a given pair of contacts
   *
   * @param $type_a
   *   Contact type
   * @param $type_b
   *   Contact type
   * @param $sub_type_a
   *   Contact sub-type
   * @param $sub_type_b
   *   Contact sub-type
   *
   * @return array
   */
  function wf_crm_get_contact_relationship_types($type_a, $type_b, $sub_type_a, $sub_type_b);

  /**
   * List dedupe rules available for a contact type
   *
   * @param string $contact_type
   * @return array
   */
  function wf_crm_get_matching_rules($contact_type);

  /**
   * Get ids or values of enabled CiviCRM fields for a webform.
   *
   * @param \Drupal\webform\WebformInterface $webform
   *   The webform.
   * @param array|null $submission
   *   (optional) if supplied, will match field keys with submitted values
   * @param boolean $show_all
   *   (optional) if true, get every field even if it belongs to a contact that does not exist
   *
   * @return array of enabled fields
   */
  function wf_crm_enabled_fields(WebformInterface $webform, $submission = NULL, $show_all = FALSE);

  /**
   * Get a field based on its short or full name
   * @param string $key
   * @return array|null
   */
  function wf_crm_get_field($key);

  /**
   * Lookup a uf ID from contact ID or vice-versa
   * With no arguments passed in, this function will return the contact_id of the current logged-in user
   *
   * @param $id
   *   (optional) uf or contact ID - defaults to current user
   * @param $type
   *   (optional) what type of ID is supplied - defaults to user id
   * @return int|null
   */
  function wf_crm_user_cid($id = NULL, $type = 'uf');

  /**
   * Fetch contact display name
   *
   * @param $cid
   *   Contact id
   *
   * @return string
   */
  function wf_crm_display_name($cid);

  /**
   * @param integer $n
   * @param array $data Form data
   * @param string $html Controls how html should be treated. Options are:
   *  * 'escape': (default) Escape html characters
   *  * 'wrap': Escape html characters and wrap in a span
   *  * 'plain': Do not escape (use when passing into an FAPI options list which does its own escaping)
   * @return string
   */
  function wf_crm_contact_label($n, $data = [], $html = 'escape');

  /**
   * Convert a | separated string into an array
   *
   * @param string $str
   *   String representation of key => value select options
   *
   * @return array of select options
   */
  function wf_crm_str2array($str);

  /**
   * Convert an array into a | separated string
   *
   * @param array $arr
   *   Array of select options
   *
   * @return string
   *   String representation of key => value select options
   */
  function wf_crm_array2str($arr);

  /**
   * Wrapper for all CiviCRM API calls
   * For consistency, future-proofing, and error handling
   *
   * @param string $entity
   *   API entity
   * @param string $operation
   *   API operation
   * @param array $params
   *   API params
   *
   * @return array
   *   Result of API call
   */
  function wf_civicrm_api($entity, $operation, $params);

  /**
   * Get the values from an api call
   *
   * @param string $entity
   *   API entity
   * @param string $operation
   *   API operation
   * @param array $params
   *   API params
   * @param string $value
   *   Reduce each result to this single value
   *
   * @return array
   *   Values from API call
   */
  function wf_crm_apivalues($entity, $operation, $params = [], $value = NULL);

  /**
   * Check if a name or email field exists for this contact.
   * This determines whether a new contact can be created on the webform.
   *
   * @param $enabled
   *   Array of enabled fields
   * @param $c
   *   Contact #
   * @param $contact_type
   *   Contact type
   * @return int
   */
  function wf_crm_name_field_exists($enabled, $c, $contact_type);

  /**
   * At least one of these fields is required to create a contact
   *
   * @param string $contact_type
   * @return array of fields
   */
  function wf_crm_required_contact_fields($contact_type);

  /**
   * These are the contact location fields this module supports
   *
   * @return array
   */
  function wf_crm_location_fields();

  /**
   * These are the address fields this module supports
   *
   * @return array
   */
  function wf_crm_address_fields();

  /**
   * @param string
   * @return array
   */
  function wf_crm_explode_multivalue_str($str);

  /**
   * Check if value is a positive integer
   * @param mixed $val
   * @return bool
   */
  function wf_crm_is_positive($val);

  /**
   * Returns empty custom civicrm field sets
   *
   * @return array $sets
   */
  function wf_crm_get_empty_sets();

  /**
   * Pull custom fields to match with Webform element types
   *
   * @return array
   */
  function wf_crm_custom_types_map_array();

  /**
   * @param string $setting_name
   * @param mixed $default_value
   * @return mixed
   */
  function wf_crm_get_civi_setting($setting_name, $default_value = NULL);

}

Members

Namesort descending Modifiers Type Description Overrides
UtilsInterface::wf_civicrm_api function Wrapper for all CiviCRM API calls For consistency, future-proofing, and error handling 1
UtilsInterface::wf_crm_address_fields function These are the address fields this module supports 1
UtilsInterface::wf_crm_apivalues function Get the values from an api call 1
UtilsInterface::wf_crm_array2str function Convert an array into a | separated string 1
UtilsInterface::wf_crm_contact_label function 1
UtilsInterface::wf_crm_custom_types_map_array function Pull custom fields to match with Webform element types 1
UtilsInterface::wf_crm_display_name function Fetch contact display name 1
UtilsInterface::wf_crm_enabled_fields function Get ids or values of enabled CiviCRM fields for a webform. 1
UtilsInterface::wf_crm_explode_key public function Explodes form key into an array and verifies that it is in the right format 1
UtilsInterface::wf_crm_explode_multivalue_str function 1
UtilsInterface::wf_crm_field_options public static function Get options for a specific field 1
UtilsInterface::wf_crm_format_event function 1
UtilsInterface::wf_crm_get_campaign_activity_types function Get activity types related to CiviCampaign 1
UtilsInterface::wf_crm_get_civi_setting function 1
UtilsInterface::wf_crm_get_contact_relationship_types function Get valid relationship types for a given pair of contacts 1
UtilsInterface::wf_crm_get_contact_types function Get contact types and sub-types Unlike pretty much every other option list CiviCRM wants "name" instead of "id" 1
UtilsInterface::wf_crm_get_empty_sets function Returns empty custom civicrm field sets 1
UtilsInterface::wf_crm_get_events function Get list of events. 1
UtilsInterface::wf_crm_get_field function Get a field based on its short or full name 1
UtilsInterface::wf_crm_get_fields public function Fetches CiviCRM field data. 1
UtilsInterface::wf_crm_get_matching_rules function List dedupe rules available for a contact type 1
UtilsInterface::wf_crm_get_privacy_options function In reality there is no contact field 'privacy' so this is not a real option list. These are actually 5 separate contact fields that this module munges into 1 for better usability. 1
UtilsInterface::wf_crm_get_relationship_types function Get relationship type data 1
UtilsInterface::wf_crm_get_states public function Get list of states, keyed by abbreviation rather than ID. 1
UtilsInterface::wf_crm_get_surveys function Get list of surveys 1
UtilsInterface::wf_crm_get_tags function Fetch tags within a given tagset 1
UtilsInterface::wf_crm_is_positive function Check if value is a positive integer 1
UtilsInterface::wf_crm_location_fields function These are the contact location fields this module supports 1
UtilsInterface::wf_crm_name_field_exists function Check if a name or email field exists for this contact. This determines whether a new contact can be created on the webform. 1
UtilsInterface::wf_crm_required_contact_fields function At least one of these fields is required to create a contact 1
UtilsInterface::wf_crm_state_abbr function Match a state/province id to its abbr. and vice-versa 1
UtilsInterface::wf_crm_str2array function Convert a | separated string into an array 1
UtilsInterface::wf_crm_user_cid function Lookup a uf ID from contact ID or vice-versa With no arguments passed in, this function will return the contact_id of the current logged-in user 1