SqlContentEntityStorage::onFieldStorageDefinitionDelete

public SqlContentEntityStorage::onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition)

Reacts to the deletion of a field storage definition.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The field being deleted.

Overrides ContentEntityStorageBase::onFieldStorageDefinitionDelete

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 1427

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition) {
  $table_mapping = $this->getTableMapping(
  $this->entityManager->getLastInstalledFieldStorageDefinitions($this->entityType->id())
  );

  // @todo Remove the FieldStorageConfigInterface check when non-configurable
  //   fields support purging: https://www.drupal.org/node/2282119.
  if ($storage_definition instanceof FieldStorageConfigInterface && $table_mapping->requiresDedicatedTableStorage($storage_definition)) {
    // Mark all data associated with the field for deletion.
    $table = $table_mapping->getDedicatedDataTableName($storage_definition);
    $revision_table = $table_mapping->getDedicatedRevisionTableName($storage_definition);
    $this->database->update($table)
      ->fields(array('deleted' => 1))
      ->execute();
    if ($this->entityType->isRevisionable()) {
      $this->database->update($revision_table)
        ->fields(array('deleted' => 1))
        ->execute();
    }
  }

  // Update the field schema.
  $this->wrapSchemaException(function() use ($storage_definition) {
    $this->getStorageSchema()->onFieldStorageDefinitionDelete($storage_definition);
  });
}
doc_Drupal
2016-10-29 09:43:27
Comments
Leave a Comment

Please login to continue.