function party_hat_context_create_party_with_hats in Party 7
Same name and namespace in other branches
- 8.2 modules/party_hat/plugins/contexts/party_new_with_hats.inc \party_hat_context_create_party_with_hats()
Create the context
1 string reference to 'party_hat_context_create_party_with_hats'
- party_new_with_hats.inc in modules/
party_hat/ plugins/ contexts/ party_new_with_hats.inc - Plugin to provide a new party context with a preconfigured set of hats.
File
- modules/
party_hat/ plugins/ contexts/ party_new_with_hats.inc, line 26 - Plugin to provide a new party context with a preconfigured set of hats.
Code
function party_hat_context_create_party_with_hats($empty, $data = NULL, $conf = FALSE) {
$context = new ctools_context(array(
'entity:party',
'entity',
'party',
));
$context->plugin = 'party_new_with_hats';
if ($empty) {
return $context;
}
// Create blank party
$context->data = party_create();
// Set hats
if (!empty($data['hats'])) {
foreach ($data['hats'] as $hat_name) {
$context->data->party_hat[LANGUAGE_NONE][] = array(
'hat_name' => $hat_name,
);
}
}
// Build context.
if (!empty($context->data)) {
$context->title = t('New Party');
return $context;
}
}