public function SqlContentEntityStorageSchema::onFieldableEntityTypeCreate in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onFieldableEntityTypeCreate()
- 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onFieldableEntityTypeCreate()
Reacts to the creation of the fieldable entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type being created.
\Drupal\Core\Field\FieldStorageDefinitionInterface[] $field_storage_definitions: The entity type's field storage definitions.
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);
}