public function Migrator::purge in Lightning Workflow 8.2
Same name and namespace in other branches
- 8.3 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 232
Class
- Migrator
- This class is final because the migration is not an API and should not be extended or re-used.
Namespace
Drupal\lightning_schedulerCode
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();
}
}