You are here

public function Migrator::purge in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8.2 modules/lightning_scheduler/src/Migrator.php \Drupal\lightning_scheduler\Migrator::purge()

Purges the data for a single base field field on a single entity type.

Only entity types with SQL storage are supported.

Parameters

string $entity_type_id: The entity type ID.

string $field_name: The name of the field to purge data.

File

modules/lightning_scheduler/src/Migrator.php, line 231

Class

Migrator
The migration is not an API and should not be extended or re-used.

Namespace

Drupal\lightning_scheduler

Code

public function purge($entity_type_id, $field_name) {
  $storage = $this->entityTypeManager
    ->getStorage($entity_type_id);
  if ($storage instanceof SqlEntityStorageInterface) {
    $table_mapping = $storage
      ->getTableMapping();
    $values = [];
    foreach ($table_mapping
      ->getColumnNames($field_name) as $column) {
      $values[$column] = NULL;
    }
    $this->database
      ->update($table_mapping
      ->getFieldTableName($field_name))
      ->fields($values)
      ->execute();
  }
}