language_hierarchy.install in Language Hierarchy 8
Same filename and directory in other branches
Installation/Upgrade functions for Language hierarchy module.
File
language_hierarchy.installView source
<?php
/**
* @file
* Installation/Upgrade functions for Language hierarchy module.
*/
/**
* Implements hook_install().
*/
function language_hierarchy_install() {
language_hierarchy_update_priorities();
}
/**
* Implements hook_schema().
*/
function language_hierarchy_schema() {
$schema = [];
$schema['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',
],
];
return $schema;
}
/**
* Create and populate language_hierarchy_priority table.
*/
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();
}
Functions
Name | Description |
---|---|
language_hierarchy_install | Implements hook_install(). |
language_hierarchy_schema | Implements hook_schema(). |
language_hierarchy_update_8001 | Create and populate language_hierarchy_priority table. |