high_contrast.install in High contrast 8
Same filename and directory in other branches
Contains install and update functions for High Contrast.
File
high_contrast.installView source
<?php
use Drupal\file\Entity\File;
/**
* @file
* Contains install and update functions for High Contrast.
*/
/**
* Implements hook_uninstall().
*/
function high_contrast_uninstall() {
$path = HIGH_CONTRAST_CSS_LOCATION;
if (file_exists($path)) {
\Drupal::service('file_system')
->delete($path);
}
}
/**
* Regenerate the CSS file in its new location.
*/
function high_contrast_update_8001() {
// Updating the CSS file is triggered by a configuration save.
\Drupal::configFactory()
->getEditable('high_contrast.settings')
->save();
}
/**
* Delete the old CSS file.
*/
function high_contrast_update_8002() {
$path = 'public://high_contrast.css';
if (file_exists($path)) {
\Drupal::service('file_system')
->delete($path);
}
}
/**
* Remove database entry for the high_contrast.css file.
*/
function high_contrast_update_8003() {
$database = \Drupal::database();
$query = $database
->query('SELECT fid FROM {file_managed} where uri=:uri', [
':uri' => HIGH_CONTRAST_CSS_LOCATION,
]);
$result = $query
->fetchAll();
foreach ($result as $record) {
$file = File::load($record->fid);
$file
->delete();
}
// Re-add the CSS file by saving configuration.
\Drupal::configFactory()
->getEditable('high_contrast.settings')
->save();
}
Functions
Name | Description |
---|---|
high_contrast_uninstall | Implements hook_uninstall(). |
high_contrast_update_8001 | Regenerate the CSS file in its new location. |
high_contrast_update_8002 | Delete the old CSS file. |
high_contrast_update_8003 | Remove database entry for the high_contrast.css file. |