function SqlContentEntityStorageSchema::onFieldableEntityTypeCreate
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onFieldableEntityTypeCreate()
- 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onFieldableEntityTypeCreate()
- 11.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onFieldableEntityTypeCreate()
Overrides EntityTypeListenerInterface::onFieldableEntityTypeCreate
1 call to SqlContentEntityStorageSchema::onFieldableEntityTypeCreate()
- SqlContentEntityStorageSchema::onEntityTypeCreate in core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorageSchema.php - Reacts to the creation of the entity type.
File
-
core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorageSchema.php, line 408
Class
- SqlContentEntityStorageSchema
- Defines a schema handler that supports revisionable, translatable entities.
Namespace
Drupal\Core\Entity\SqlCode
public function onFieldableEntityTypeCreate(EntityTypeInterface $entity_type, array $field_storage_definitions) {
// When installing a fieldable entity type, we have to use the provided
// entity type and field storage definitions.
$this->entityType = $entity_type;
$this->fieldStorageDefinitions = $field_storage_definitions;
$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.
$table_mapping = $this->getTableMapping($this->entityType);
foreach ($this->fieldStorageDefinitions 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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.