You are here

function language_hierarchy_update_8001 in Language Hierarchy 2.x

Same name and namespace in other branches
  1. 8 language_hierarchy.install \language_hierarchy_update_8001()

Create and populate language_hierarchy_priority table.

File

./language_hierarchy.install, line 46
Installation/Upgrade functions for Language hierarchy module.

Code

function language_hierarchy_update_8001() {
  $database = \Drupal::service('database');
  $database
    ->schema()
    ->createTable('language_hierarchy_priority', [
    'description' => 'Holds relative priorities for all langcodes, with respect to the global hierarchy of language fallbacks.',
    'fields' => [
      'langcode' => [
        'description' => 'An entity langcode.',
        'type' => 'varchar_ascii',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ],
      'priority' => [
        'description' => 'The higher the value, the more relevant the langcode. For any child language, this will be its depth. Otherwise it will be the weight of the language.',
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'langcode',
    ],
  ]);
  language_hierarchy_update_priorities();
}