imagecache_external.install in Imagecache External 8
Same filename and directory in other branches
Uninstall, install, and update functions.
File
imagecache_external.installView source
<?php
/**
* @file
* Uninstall, install, and update functions.
*/
use Drupal\Core\Url;
/**
* Implements hook_requirements().
*/
function imagecache_external_requirements($phase) {
$config = \Drupal::config('imagecache_external.settings');
$requirements = [];
// Check the Imagecache External configuration.
if ($phase == 'runtime') {
$hosts = $config
->get('imagecache_external_hosts');
$use_whitelist = $config
->get('imagecache_external_use_whitelist');
if ($use_whitelist && empty($hosts)) {
$requirements['imagecache_external'] = [
'title' => t('Imagecache External'),
'value' => t('Not properly configured'),
'description' => t('The configuration is set to use a whitelist but no hostname(s) are configured. <a href="@link">Add one or more trusted hostnames</a> or <a href="@link">disable the whitelist functionality</a>.', [
'@link' => Url::fromRoute('imagecache_external.admin_settings')
->toString(),
]),
'severity' => REQUIREMENT_WARNING,
];
}
else {
$requirements['imagecache_external'] = [
'title' => t('Imagecache External'),
'value' => t('Properly configured'),
'severity' => REQUIREMENT_OK,
];
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function imagecache_external_uninstall() {
\Drupal::state()
->delete('imagecache_external.last_cron_flush');
}
/**
* Add imagecache_external_batch_flush_limit to the default configuration.
*/
function imagecache_external_update_8101() {
$config_factory = \Drupal::configFactory();
$config = $config_factory
->getEditable('imagecache_external.settings');
$config
->set('imagecache_external_batch_flush_limit', 1000);
$config
->save(TRUE);
}
Functions
Name | Description |
---|---|
imagecache_external_requirements | Implements hook_requirements(). |
imagecache_external_uninstall | Implements hook_uninstall(). |
imagecache_external_update_8101 | Add imagecache_external_batch_flush_limit to the default configuration. |