function Schema::mapKeyDefinition

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema::mapKeyDefinition()
  2. 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::mapKeyDefinition()
  3. 11.x core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::mapKeyDefinition()

Utility method: rename columns in an index definition according to a new mapping.

Parameters

$key_definition: The key definition.

$mapping: The new mapping.

1 call to Schema::mapKeyDefinition()
Schema::changeField in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php

File

core/modules/sqlite/src/Driver/Database/sqlite/Schema.php, line 665

Class

Schema
SQLite implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

protected function mapKeyDefinition(array $key_definition, array $mapping) {
    foreach ($key_definition as &$field) {
        // The key definition can be an array($field, $length).
        if (is_array($field)) {
            $field =& $field[0];
        }
        $mapped_field = array_search($field, $mapping, TRUE);
        if ($mapped_field !== FALSE) {
            $field = $mapped_field;
        }
    }
    return $key_definition;
}

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