You are here

function gathercontent_update_8301 in GatherContent 8.3

Same name and namespace in other branches
  1. 8.5 gathercontent.install \gathercontent_update_8301()
  2. 8.4 gathercontent.install \gathercontent_update_8301()

Create gathercontent_option_ids field if doesn't exist.

File

./gathercontent.install, line 86
Install and uninstall script for GatherContent module.

Code

function gathercontent_update_8301() {

  /** @var \Drupal\Core\Entity\EntityFieldManager $entityFieldManager */
  $entityFieldManager = \Drupal::service('entity_field.manager');
  $definitions = $entityFieldManager
    ->getFieldStorageDefinitions('taxonomy_term');
  if (!isset($definitions['gathercontent_option_ids'])) {
    FieldStorageConfig::create([
      'field_name' => 'gathercontent_option_ids',
      'entity_type' => 'taxonomy_term',
      'type' => 'string',
      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
      'locked' => TRUE,
      'persist_with_no_fields' => TRUE,
      'settings' => [
        'is_ascii' => FALSE,
        'case_sensitive' => FALSE,
      ],
    ])
      ->save();
  }
}