You are here

function serial_field_config_create in Serial Field 8

Implements hook_ENTITY_TYPE_create().

@inheritdoc

File

./serial.module, line 31
The Serial module main file.

Code

function serial_field_config_create(FieldConfig $field) {
  if ($field
    ->getType() == 'serial' && !$field
    ->isDeleted()) {

    // Create the assistant storage.

    /** @var \Drupal\serial\SerialStorageInterface $serialStorage */
    $serialStorage = \Drupal::getContainer()
      ->get('serial.sql_storage');
    $storageName = $serialStorage
      ->createStorageName($field
      ->getTargetEntityTypeId(), $field
      ->getTargetBundle(), $field
      ->getFieldStorageDefinition()
      ->getName());
    $serialStorage
      ->createStorageFromName($storageName);
    $field
      ->save();
  }
}