You are here

function consumers_update_8104 in Consumers 8

Add field 'is_default'.

File

./consumers.install, line 67
Install, update and uninstall functions for Consumers.

Code

function consumers_update_8104() {
  $field_definition = BaseFieldDefinition::create('boolean')
    ->setLabel(new TranslatableMarkup('Is this the default consumer?'))
    ->setDescription(new TranslatableMarkup('There can only be one default consumer. Mark this to use this consumer when none other applies.'))
    ->setDisplayOptions('view', [
    'label' => 'inline',
    'type' => 'boolean',
    'weight' => 4,
  ])
    ->setDisplayOptions('form', [
    'weight' => 4,
  ])
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE)
    ->setDefaultValue(FALSE)
    ->setInitialValue(FALSE);
  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('is_default', 'consumer', 'consumers', $field_definition);
}