You are here

function party_hat_get_hats in Party 8.2

Same name and namespace in other branches
  1. 7 modules/party_hat/party_hat.module \party_hat_get_hats()

Get all the Hats a Party is Wearing

Parameters

$party: The Party object or ID

6 calls to party_hat_get_hats()
PartyHatPartyUIController::overviewTableRow in modules/party_hat/includes/party_hat.entity.inc
Generates the row for the passed entity and may be overridden in order to customize the rows.
party_hat_party_data_sets_alter in modules/party_hat/party_hat.module
Implements hook_party_data_sets_alter().
party_hat_party_form_hat_submit in modules/party_hat/party_hat.module
Trigger Rules etc when a hat is assigned.
party_hat_party_form_hat_validate in modules/party_hat/party_hat.module
Additional validate handler to check party form for expected attached entities.
party_hat_party_hat_ctools_access_check in modules/party_hat/plugins/access/party_hat.inc
Check for access.

... See full list

File

modules/party_hat/party_hat.module, line 281
party_hat.module Provides an extensible access system for parties.

Code

function party_hat_get_hats($party) {
  if (!is_object($party)) {
    $party = party_load($party);
  }
  $hats = array();
  $items = field_get_items('party', $party, 'party_hat');

  // If there are no hats set, lead the required ones.
  if (empty($items)) {
    $options = array(
      'required' => TRUE,
    );
    return party_hat_get_all_hats($options);
  }
  else {
    foreach ($items as $item) {
      $hat = party_hat_load($item['hat_name']);
      $hats[$hat->name] = $hat;
    }
  }
  return $hats;
}