public SqlContentEntityStorageSchema::onEntityTypeCreate(EntityTypeInterface $entity_type)
Reacts to the creation of the entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type being created.
Overrides EntityTypeListenerInterface::onEntityTypeCreate
File
- core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 259
Class
- SqlContentEntityStorageSchema
- Defines a schema handler that supports revisionable, translatable entities.
Namespace
Drupal\Core\Entity\Sql
Code
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); }
Please login to continue.