public function SqlContentEntityStorageSchema::onEntityTypeCreate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeCreate()
Reacts to the creation of the entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type being created.
Overrides EntityTypeListenerInterface::onEntityTypeCreate
1 call to SqlContentEntityStorageSchema::onEntityTypeCreate()
- SqlContentEntityStorageSchema::onEntityTypeUpdate in core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorageSchema.php - Reacts to the update of the entity type.
File
- core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorageSchema.php, line 264 - Contains \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema.
Class
- SqlContentEntityStorageSchema
- Defines a schema handler that supports revisionable, translatable entities.
Namespace
Drupal\Core\Entity\SqlCode
public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
$this
->checkEntityType($entity_type);
$schema_handler = $this->database
->schema();
// Create entity tables.
$schema = $this
->getEntitySchema($entity_type, TRUE);
foreach ($schema as $table_name => $table_schema) {
if (!$schema_handler
->tableExists($table_name)) {
$schema_handler
->createTable($table_name, $table_schema);
}
}
// Create dedicated field tables.
$field_storage_definitions = $this->entityManager
->getFieldStorageDefinitions($entity_type
->id());
$table_mapping = $this->storage
->getTableMapping($field_storage_definitions);
foreach ($field_storage_definitions as $field_storage_definition) {
if ($table_mapping
->requiresDedicatedTableStorage($field_storage_definition)) {
$this
->createDedicatedTableSchema($field_storage_definition);
}
elseif ($table_mapping
->allowsSharedTableStorage($field_storage_definition)) {
// The shared tables are already fully created, but we need to save the
// per-field schema definitions for later use.
$this
->createSharedTableSchema($field_storage_definition, TRUE);
}
}
// Save data about entity indexes and keys.
$this
->saveEntitySchemaData($entity_type, $schema);
}