class TemporaryTableMapping

Defines a temporary table mapping class.

Hierarchy

Expanded class hierarchy of TemporaryTableMapping

Deprecated

in drupal:8.7.0 and is removed from drupal:9.0.0. Use the default table mapping with a prefix instead.

1 file declares its use of TemporaryTableMapping
DefaultTableMappingTest.php in core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php

File

core/lib/Drupal/Core/Entity/Sql/TemporaryTableMapping.php, line 15

Namespace

Drupal\Core\Entity\Sql
View source
class TemporaryTableMapping extends DefaultTableMapping {
    
    /**
     * {@inheritdoc}
     */
    protected function generateFieldTableName(FieldStorageDefinitionInterface $storage_definition, $revision) {
        return static::getTempTableName(parent::generateFieldTableName($storage_definition, $revision));
    }
    
    /**
     * Generates a temporary table name.
     *
     * The method accounts for a maximum table name length of 64 characters.
     *
     * @param string $table_name
     *   The initial table name.
     * @param string $prefix
     *   (optional) The prefix to use for the new table name. Defaults to 'tmp_'.
     *
     * @return string
     *   The final table name.
     */
    public static function getTempTableName($table_name, $prefix = 'tmp_') {
        $tmp_table_name = $prefix . $table_name;
        // Limit the string to 48 characters, keeping a 16 characters margin for db
        // prefixes.
        if (strlen($table_name) > 48) {
            $short_table_name = substr($table_name, 0, 34);
            $table_hash = substr(hash('sha256', $table_name), 0, 10);
            $tmp_table_name = $prefix . $short_table_name . $table_hash;
        }
        return $tmp_table_name;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DefaultTableMapping::$allColumns protected property A list of all database columns per table.
DefaultTableMapping::$baseTable protected property The base table of the entity.
DefaultTableMapping::$columnMapping protected property A mapping of column names per field name.
DefaultTableMapping::$dataTable protected property The table that stores field data, if the entity has multilingual support.
DefaultTableMapping::$entityType protected property The entity type definition.
DefaultTableMapping::$extraColumns protected property A list of database columns which store denormalized data per table.
DefaultTableMapping::$fieldNames protected property A list of field names per table.
DefaultTableMapping::$fieldStorageDefinitions protected property The field storage definitions of this mapping.
DefaultTableMapping::$prefix protected property The prefix to be used by all the tables of this mapping.
DefaultTableMapping::$revisionDataTable protected property The table that stores revision field data if the entity supports revisions
and has multilingual support.
DefaultTableMapping::$revisionTable protected property The table that stores revisions, if the entity supports revisions.
DefaultTableMapping::allowsSharedTableStorage public function Checks whether the given field can be stored in a shared table.
DefaultTableMapping::create public static function Initializes the table mapping.
DefaultTableMapping::getAllColumns public function Gets a list of all database columns for a given table. Overrides TableMappingInterface::getAllColumns
DefaultTableMapping::getBaseTable public function Gets the base table name.
DefaultTableMapping::getColumnNames public function Gets a mapping of field columns to database columns for a given field. Overrides TableMappingInterface::getColumnNames
DefaultTableMapping::getDataTable public function Gets the data table name.
DefaultTableMapping::getDedicatedDataTableName public function Generates a table name for a field data table.
DefaultTableMapping::getDedicatedRevisionTableName public function Generates a table name for a field revision archive table.
DefaultTableMapping::getDedicatedTableNames public function Gets a list of dedicated table names for this mapping.
DefaultTableMapping::getExtraColumns public function Gets a list of extra database columns, which store denormalized data. Overrides TableMappingInterface::getExtraColumns
DefaultTableMapping::getFieldColumnName public function Generates a column name for a field property. Overrides TableMappingInterface::getFieldColumnName
DefaultTableMapping::getFieldNames public function Gets a list of names for entity fields stored in the specified table. Overrides TableMappingInterface::getFieldNames
DefaultTableMapping::getFieldTableName public function Gets the table name for a given column. Overrides TableMappingInterface::getFieldTableName
DefaultTableMapping::getReservedColumns public function Gets the list of columns that can not be used as field type columns. Overrides TableMappingInterface::getReservedColumns
DefaultTableMapping::getRevisionDataTable public function Gets the revision data table name.
DefaultTableMapping::getRevisionTable public function Gets the revision table name.
DefaultTableMapping::getTableNames public function Gets a list of table names for this mapping. Overrides TableMappingInterface::getTableNames
DefaultTableMapping::requiresDedicatedTableStorage public function Checks whether the given field has to be stored in a dedicated table.
DefaultTableMapping::setExtraColumns public function Adds a extra columns for a table to the table mapping. 2
DefaultTableMapping::setFieldNames public function Adds field columns for a table to the table mapping. 2
DefaultTableMapping::__construct public function Constructs a DefaultTableMapping.
TableMappingInterface::DELTA constant A property that represents delta used in entity query conditions.
TemporaryTableMapping::generateFieldTableName protected function Generates a safe and unambiguous field table name. Overrides DefaultTableMapping::generateFieldTableName
TemporaryTableMapping::getTempTableName public static function Generates a temporary table name.

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