You are here

function social_tagging_update_8003 in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_tagging/social_tagging.install \social_tagging_update_8003()
  2. 10.0.x modules/social_features/social_tagging/social_tagging.install \social_tagging_update_8003()
  3. 10.1.x modules/social_features/social_tagging/social_tagging.install \social_tagging_update_8003()

Install Tagging base field to profile entity type.

File

modules/social_features/social_tagging/social_tagging.install, line 86
Installation file for Social Tagging.

Code

function social_tagging_update_8003() {
  $field_storage_definition = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Tagging'))
    ->setDescription(t('Tagging field.'))
    ->setSetting('target_type', 'taxonomy_term')
    ->setSetting('handler', 'default:taxonomy_term')
    ->setSetting('handler_settings', [
    'target_bundles' => [
      'social_tagging' => 'social_tagging',
    ],
  ])
    ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
    ->setDisplayOptions('view', [
    'type' => 'hidden',
  ])
    ->setDisplayOptions('form', [
    'type' => 'options_select',
    'weight' => 3,
    'settings' => [],
  ])
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE);
  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('social_tagging', 'profile', 'social_tagging', $field_storage_definition);
}