function panopoly_widgets_update_7023 in Panopoly Widgets 7
Make sure that "Slide duration" on Spotlight widgets always has a value.
File
- ./
panopoly_widgets.install, line 492 - An installation file for Panopoly Widgets
Code
function panopoly_widgets_update_7023(&$sandbox) {
if (!isset($sandbox['fpids'])) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'fieldable_panels_pane')
->entityCondition('bundle', 'spotlight');
$result = $query
->execute();
if (isset($result['fieldable_panels_pane'])) {
$sandbox['fpids'] = array_keys($result['fieldable_panels_pane']);
}
}
else {
$count = 10;
while (!empty($sandbox['fpids']) && $count >= 0) {
$fpp = fieldable_panels_panes_load(array_shift($sandbox['fpids']));
$wrapper = entity_metadata_wrapper('fieldable_panels_pane', $fpp);
if (!$wrapper->field_basic_spotlight_duration
->value()) {
$wrapper->field_basic_spotlight_duration
->set(variable_get('panopoly_widgets_spotlight_rotation_time', 5));
$wrapper
->save();
}
}
}
$sandbox['#finished'] = empty($sandbox['fpids']);
if ($sandbox['#finished']) {
variable_del('panopoly_widgets_spotlight_rotation_time');
}
}