function DefaultTableMapping::__construct

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php \Drupal\Core\Entity\Sql\DefaultTableMapping::__construct()
  2. 8.9.x core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php \Drupal\Core\Entity\Sql\DefaultTableMapping::__construct()
  3. 11.x core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php \Drupal\Core\Entity\Sql\DefaultTableMapping::__construct()

Constructs a DefaultTableMapping.

Parameters

\Drupal\Core\Entity\ContentEntityTypeInterface $entity_type: The entity type definition.

\Drupal\Core\Field\FieldStorageDefinitionInterface[] $storage_definitions: A list of field storage definitions that should be available for the field columns of this table mapping.

string $prefix: (optional) A prefix to be used by all the tables of this mapping. Defaults to an empty string.

File

core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php, line 128

Class

DefaultTableMapping
Defines a default table mapping class.

Namespace

Drupal\Core\Entity\Sql

Code

public function __construct(ContentEntityTypeInterface $entity_type, array $storage_definitions, $prefix = '') {
    $this->entityType = $entity_type;
    $this->fieldStorageDefinitions = $storage_definitions;
    $this->prefix = $prefix;
    // @todo Remove table names from the entity type definition in
    //   https://www.drupal.org/node/2232465.
    $this->baseTable = $this->prefix . $entity_type->getBaseTable() ?: $entity_type->id();
    if ($entity_type->isRevisionable()) {
        $this->revisionTable = $this->prefix . $entity_type->getRevisionTable() ?: $entity_type->id() . '_revision';
    }
    if ($entity_type->isTranslatable()) {
        $this->dataTable = $this->prefix . $entity_type->getDataTable() ?: $entity_type->id() . '_field_data';
    }
    if ($entity_type->isRevisionable() && $entity_type->isTranslatable()) {
        $this->revisionDataTable = $this->prefix . $entity_type->getRevisionDataTable() ?: $entity_type->id() . '_field_revision';
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.