function commerce_registration_defer_install in Commerce Registration 7.2
Implements hook_install().
File
- modules/
commerce_registration_defer/ commerce_registration_defer.install, line 11 - Schema and installation hooks for commerce_registration_defer module.
Code
function commerce_registration_defer_install() {
// Create deferred states.
$states = array(
'deferred' => array(
'label' => 'Deferred',
'description' => 'Registration was deferred',
'default_state' => 0,
'active' => 0,
'held' => 0,
'show_on_form' => 0,
'weight' => 2,
),
);
$registration_states = db_query('SELECT rs.name as state FROM {registration_state} rs')
->fetchCol();
// Don't add the deferred states if they already exist.
if ($registration_states) {
$registration_states = array_flip($registration_states);
$states = array_diff_key($states, $registration_states);
}
foreach ($states as $state_name => $state_label) {
$registration_state = entity_create('registration_state', array(
'name' => $state_name,
'label' => $state_label['label'],
'description' => $state_label['description'],
'default_state' => $state_label['default_state'],
'active' => $state_label['active'],
'held' => $state_label['held'],
'show_on_form' => $state_label['show_on_form'],
'weight' => $state_label['weight'],
));
$registration_state
->save();
}
}