hovercss-1.0.3/hovercss_ui/hovercss_ui.install
hovercss_ui/hovercss_ui.install
<?php
/**
* @file
* Install, update and uninstall functions for the HoverCSS module.
*/
use Drupal\Core\Url;
/**
* Implements hook_schema().
*/
function hovercss_ui_schema() {
$schema['hovercss'] = [
'description' => 'Stores hover css selectors.',
'fields' => [
'hid' => [
'description' => 'Primary Key: unique ID for hover css selectors.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'selector' => [
'description' => 'Hover css selector.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'label' => [
'description' => 'Label of hover css.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'comment' => [
'description' => 'Comment for hover css.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
],
'changed' => [
'description' => 'Timestamp when the hover was most recently modified.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
],
'status' => [
'description' => 'Boolean indicating whether the hover is enabled.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
],
'options' => [
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'description' => 'The options data in serialized form.',
],
],
'indexes' => [
'label' => ['label'],
'selector' => ['selector'],
'changed' => ['changed'],
],
'primary key' => ['hid'],
];
return $schema;
}
/**
* Implements hook_install().
*/
function hovercss_ui_install() {
// Add HoverCSS settings link status.
\Drupal::messenger()->addStatus(t('Configure HoverCSS <a href=":settings">global settings</a>.', [
':settings' => Url::fromRoute('hovercss.settings')->toString(),
]));
}
/**
* Implements hook_uninstall().
*/
function hovercss_ui_uninstall() {
// If uninstall and re-install hovercss_ui module will show error:
// Unable to install HoverCSS UI, hovercss.settings already
// exists in active configuration.
$query = \Drupal::database()->delete('config');
// Delete set variables in hovercss_ui uninstall, because
// of name "hovercss.settings" it will delete in "hovercss"
// module uninstall, will not delete in "hovercss_ui" uninstall.
$query->condition('name', 'hovercss.settings');
$query->execute();
}
/**
* Added a new field for hide hover warning configuration.
*/
function hovercss_ui_update_8000() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('hovercss.settings');
// Add new hide configuration field.
$config->set('hide', FALSE);
$config->save(TRUE);
}
