You are here

function party_get_data_set in Party 8.2

Return a Data Set object containing all the attached entities in a given data set for a particular party.

Parameters

$party: The party object of the party we're concerned with.

$set_name: The set type as defined in hook_party_data_set_info().

$create: Choose to create an entity if there isn't already at least one.

Return value

A party data set object with attached entities available

2 calls to party_get_data_set()
party_get_all_emails in modules/party_simplenews/party_simplenews.module
Get all the emails on a Party
party_get_attached_entities in ./party.module
Return all attached entities of a particular set.

File

./party.module, line 959
Provides a generic CRM party entity.

Code

function party_get_data_set($party, $data_set_name, $create = FALSE) {
  if (!$party) {
    drupal_set_message(t('Party not set, unable to load attached entities.'), 'error');
    return array();
  }
  $data_set_controller = party_get_crm_controller($party, $data_set_name);
  $entity_ids = $data_set_controller
    ->getEntityIds();
  if ($create && empty($entity_ids)) {
    $entity = $data_set_controller
      ->createEntity();
    $data_set_controller
      ->attachEntity($entity);
  }
  return $data_set_controller;
}