function SqlContentEntityStorage::setEntityType

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::setEntityType()
  2. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::setEntityType()
  3. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::setEntityType()

Updates the wrapped entity type definition.

@internal Only to be used internally by Entity API. Expected to be removed by https://www.drupal.org/node/2274017.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The update entity type.

File

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

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

public function setEntityType(EntityTypeInterface $entity_type) {
    if ($this->entityType
        ->id() == $entity_type->id()) {
        $this->entityType = $entity_type;
        $this->initTableLayout();
    }
    else {
        throw new EntityStorageException("Unsupported entity type {$entity_type->id()}");
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.