You are here

function party_hat_build_hat_options in Party 7

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

Build a set of hats for EntityMetadataWrapper::optionsList().

If $op is edit, they are labeled to show heirachy with hyphens for indents.

Return value

array An array of hat labels keyed by value.

See also

EntityMetadataWrapper::optionsList().

2 calls to party_hat_build_hat_options()
party_hat_context_party_with_hats_settings_form in modules/party_hat/plugins/contexts/party_new_with_hats.inc
Build settings form.
party_hat_options_list in modules/party_hat/party_hat.module
Implements hook_options_list().
1 string reference to 'party_hat_build_hat_options'
party_hat_entity_metadata_field_hat_reference_callback in modules/party_hat/party_hat.module
Callback to adapt the property info for party hat reference fields.

File

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

Code

function party_hat_build_hat_options($name, $info, $op) {
  $hats = party_hat_get_tree();

  // Add an indent if we're in edit mode to demonstrate heirachy.
  $indent = $op == 'edit' ? '-' : '';
  $options = array();
  foreach ($hats as $hat) {
    $options[$hat->name] = str_repeat($indent, $hat->depth) . $hat->label;
  }
  return $options;
}