You are here

function imagecache_external_requirements in Imagecache External 8

Same name and namespace in other branches
  1. 7.2 imagecache_external.install \imagecache_external_requirements()

Implements hook_requirements().

File

./imagecache_external.install, line 11
Uninstall, install, and update functions.

Code

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;
}