You are here

function preview_link_update_8204 in Preview Link 2.x

Same name and namespace in other branches
  1. 2.0.x preview_link.install \preview_link_update_8204()

Add the 'entities' field to 'preview_link' entities.

File

./preview_link.install, line 73
Install file.

Code

function preview_link_update_8204() : TranslatableMarkup {
  $storageDefinition = BaseFieldDefinition::create('dynamic_entity_reference')
    ->setLabel(t('Entities'))
    ->setDescription(t('The associated entities this preview link unlocks.'))
    ->setRequired(TRUE)
    ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
    ->addConstraint('PreviewLinkEntitiesUniqueConstraint', [])
    ->setSettings(PreviewLink::entitiesDefaultFieldSettings())
    ->setDisplayOptions('form', [
    'type' => 'preview_link_entities_widget',
    'weight' => 10,
  ]);
  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('entities', 'preview_link', 'preview_link', $storageDefinition);
  return \t("Add the 'entities' field to 'preview_link' entities.");
}