ispim-1.0.x-dev/ispim.install
ispim.install
<?php
/**
* @file
* Install, update and uninstall functions for the ISPIM module.
*/
declare(strict_types=1);
use Drupal\ispim\Entity\IspimPreviewImageInterface;
/**
* Implements hook_install().
*/
function ispim_install(bool $is_syncing): void {
if (!$is_syncing) {
$container = \Drupal::getContainer();
$configFactory = $container->get('config.factory');
// File ./config/install/ispim.ispim_preview_image.settings.yml contains a
// hard-coded value, which can be different than the system default.
$settings = $configFactory->getEditable('ispim.ispim_preview_image.settings');
$initialValue = $settings->get('image.storage_settings.uri_scheme');
$defaultValue = $configFactory->get('system.file')->get('default_scheme');
if ($initialValue !== $defaultValue) {
$settings
->set('image.storage_settings.uri_scheme', $defaultValue)
->save();
}
}
}
/**
* Implements hook_uninstall().
*/
function ispim_uninstall(bool $is_syncing): void {
if (!$is_syncing) {
\Drupal::configFactory()
->getEditable('image.settings')
->set('preview_image', IspimPreviewImageInterface::DEFAULT_PREVIEW_IMAGE)
->save();
}
}
