function image_requirements

image_requirements($phase)

Implements hook_requirements() to check the PHP GD Library.

Parameters

$phase:

File

core/modules/image/image.install, line 30
Install, update and uninstall functions for the image module.

Code

function image_requirements($phase) {
  if ($phase != 'runtime') {
    return array();
  }

  $toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit();
  if ($toolkit) {
    $plugin_definition = $toolkit->getPluginDefinition();
    $requirements = array(
      'image.toolkit' => array(
        'title' => 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 = array(
      'image.toolkit' => array(
        'title' => t('Image toolkit'),
        'value' => t('None'),
        'description' => 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 enabled."),
        'severity' => REQUIREMENT_ERROR,
      ),
    );
  }

  return $requirements;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!image!image.install/function/image_requirements/8.1.x