public SqlContentEntityStorageSchema::onEntityTypeCreate(EntityTypeInterface $entity_type)
Reacts to the creation of the entity type.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type being created.
Overrides EntityTypeListenerInterface::onEntityTypeCreate
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); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorageSchema.php/function/SqlContentEntityStorageSchema::onEntityTypeCreate/8.1.x