function DefaultTableMapping::__construct

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

Constructs a DefaultTableMapping.

Parameters

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

\Drupal\Core\Field\FieldStorageDefinitionInterface[] $fieldStorageDefinitions: 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 107

Class

DefaultTableMapping
Defines a default table mapping class.

Namespace

Drupal\Core\Entity\Sql

Code

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

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