bootstrap_simple_carousel.install in bootstrap simple carousel 8
Defines install of bootstrap simple carousel.
File
bootstrap_simple_carousel.installView source
<?php
/**
* @file
* Defines install of bootstrap simple carousel.
*/
use Drupal\Core\Database\Database;
use Drupal\bootstrap_simple_carousel\Form\SettingsForm;
/**
* Implements hook_schema().
*/
function bootstrap_simple_carousel_schema() {
$schema['bootstrap_simple_carousel'] = [
'description' => 'Items of the carousel module.',
'fields' => [
'cid' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'image_id' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'image_alt' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
],
'image_title' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
],
'image_link' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => FALSE,
'default' => '',
],
'caption_title' => [
'type' => 'varchar',
'length' => 100,
'not null' => FALSE,
'default' => '',
],
'caption_text' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
],
'weight' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'status' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
],
],
'primary key' => [
'cid',
],
];
return $schema;
}
/**
* Add a weight field to {bootstrap_simple_carousel} table.
*/
function bootstrap_simple_carousel_update_8300() {
$weight = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
];
$schema = Database::getConnection()
->schema();
$schema
->addField('bootstrap_simple_carousel', 'weight', $weight);
}
/**
* Add a weight field to {bootstrap_simple_carousel} table.
*/
function bootstrap_simple_carousel_update_8400() {
$image_link = [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
];
$schema = Database::getConnection()
->schema();
$schema
->addField('bootstrap_simple_carousel', 'image_link', $image_link);
$config_factory = \Drupal::configFactory();
$config = $config_factory
->getEditable('bootstrap_simple_carousel.settings');
$image_fluid = $config
->get('image_fluid');
if ($image_fluid) {
$config
->set('image_type', SettingsForm::FLUID_IMAGE_TYPE_ID)
->save(TRUE);
}
}
/**
* Add a weight field to {bootstrap_simple_carousel} table.
*/
function bootstrap_simple_carousel_update_8410() {
$database = \Drupal::database();
$database
->query("ALTER TABLE {bootstrap_simple_carousel} MODIFY image_alt VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci;");
$database
->query("ALTER TABLE {bootstrap_simple_carousel} MODIFY image_title VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci;");
$database
->query("ALTER TABLE {bootstrap_simple_carousel} MODIFY caption_title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;");
$database
->query("ALTER TABLE {bootstrap_simple_carousel} MODIFY caption_text VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci;");
}
/**
* Install the container configuration entity type.
*/
function bootstrap_simple_carousel_update_8630() {
$type_manager = \Drupal::entityTypeManager();
$type_manager
->clearCachedDefinitions();
$entity_type = $type_manager
->getDefinition('bootstrap_simple_carousel');
\Drupal::entityDefinitionUpdateManager()
->installEntityType($entity_type);
return t('Installed the {bootstrap_simple_carousel} entity type');
}
Functions
Name | Description |
---|---|
bootstrap_simple_carousel_schema | Implements hook_schema(). |
bootstrap_simple_carousel_update_8300 | Add a weight field to {bootstrap_simple_carousel} table. |
bootstrap_simple_carousel_update_8400 | Add a weight field to {bootstrap_simple_carousel} table. |
bootstrap_simple_carousel_update_8410 | Add a weight field to {bootstrap_simple_carousel} table. |
bootstrap_simple_carousel_update_8630 | Install the container configuration entity type. |