You are here

function viewfield_update_8303 in Viewfield 8.3

Add field for items_to_display.

File

./viewfield.install, line 89
Install, update and uninstall functions for the viewfield module.

Code

function viewfield_update_8303() {
  $property = 'items_to_display';
  if (!($field_configs = \Drupal::entityTypeManager()
    ->getStorage('field_config')
    ->loadByProperties([
    'field_type' => 'viewfield',
  ]))) {
    return;
  }
  foreach ($field_configs as $field) {

    /** @var \Drupal\Core\Field\FieldConfigInterface $field */
    $default_values = $field
      ->getDefaultValueLiteral();
    foreach ($default_values as $key => $value) {
      $default_values[$key][$property] = '';
    }
    $field
      ->setDefaultValue($default_values);
    $field
      ->save();
  }
}