function ImageRequirements::runtime

Implements hook_runtime_requirements().

Attributes

#[Hook('runtime_requirements')]

File

core/modules/image/src/Hook/ImageRequirements.php, line 26

Class

ImageRequirements
Requirements for the Image module.

Namespace

Drupal\image\Hook

Code

public function runtime() : array {
  $toolkit = $this->imageToolkitManager
    ->getDefaultToolkit();
  if ($toolkit) {
    $plugin_definition = $toolkit->getPluginDefinition();
    $requirements = [
      'image.toolkit' => [
        'title' => $this->t('Image toolkit'),
        'value' => $toolkit->getPluginId(),
        'description' => $plugin_definition['title'],
      ],
    ];
    foreach ($toolkit->getRequirements() as $key => $requirement) {
      $namespaced_key = 'image.toolkit.' . $toolkit->getPluginId() . '.' . $key;
      $requirements[$namespaced_key] = $requirement;
    }
  }
  else {
    $requirements = [
      'image.toolkit' => [
        'title' => $this->t('Image toolkit'),
        'value' => $this->t('None'),
        'description' => $this->t("No image toolkit is configured on the site. Check PHP installed extensions or add a contributed toolkit that doesn't require a PHP extension. Make sure that at least one valid image toolkit is installed."),
        'severity' => RequirementSeverity::Error,
      ],
    ];
  }
  return $requirements;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.