function office_hours_update_8004 in Office Hours 8
Update 'comment' config.
Parameters
mixed $sandbox: The sandbox variable.
File
- ./
office_hours.install, line 54 - Install, update and uninstall functions for the Office hours module.
Code
function office_hours_update_8004(&$sandbox) {
// Create config factory.
$config_factory = \Drupal::configFactory();
// Find all base storage fields.
foreach ($config_factory
->listAll('field.storage') as $field_storage_name) {
// Load the field conig object.
$field = $config_factory
->getEditable($field_storage_name);
// Grab the field type.
$type = $field
->get('type');
if ($type == 'office_hours') {
if ($field
->get('settings.comment') === FALSE) {
$field
->set('settings.comment', 0);
}
if ($field
->get('settings.comment') === TRUE) {
$field
->set('settings.comment', 1);
}
// Save the updated config object.
$field
->save(TRUE);
}
}
}