function party_hat_get_all_hats in Party 7
Same name and namespace in other branches
- 8.2 modules/party_hat/party_hat.module \party_hat_get_all_hats()
Get all available hats.
@todo: Make filter by party type.
7 calls to party_hat_get_all_hats()
- party_devel_info_page in ./
party.admin.inc - Menu callback of development information.
- party_hat_field_get_default in modules/
party_hat/ party_hat.module - Get Required Hats for Field Values
- party_hat_get_hats in modules/
party_hat/ party_hat.module - Get all the Hats a Party is Wearing
- party_hat_get_tree in modules/
party_hat/ party_hat.module - Build a hierarchical representation of hats.
- party_hat_party_hat_ctools_access_settings in modules/
party_hat/ plugins/ access/ party_hat.inc - Settings form for the 'by term' access plugin
File
- modules/
party_hat/ party_hat.module, line 325 - party_hat.module Provides an extensible access system for parties.
Code
function party_hat_get_all_hats($options = array()) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'party_hat', '=');
if (isset($options['required']) && $options['required']) {
// filter the search by whether they're required
$query
->propertyCondition('required', 1, '=');
}
$result = $query
->execute();
if (!isset($result['party_hat']) || !is_array($result['party_hat'])) {
return array();
}
// Get the array keyed by hat name.
$hats = array();
foreach (entity_load('party_hat', array_keys($result['party_hat'])) as $hat) {
$hats[$hat->name] = $hat;
}
return $hats;
}