public function ImageToolkitManager::getDefaultToolkit

Gets the default image toolkit.

Parameters

string $toolkit_id: (optional) String specifying toolkit to load. NULL will load the default toolkit.

Return value

\Drupal\system\Plugin\ImageToolkitInterface Object of the default toolkit, or FALSE on error.

File

drupal/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php, line 41
Contains \Drupal\system\Plugin\ImageToolkitManager.

Class

ImageToolkitManager
Manages toolkit plugins.

Namespace

Drupal\system\Plugin

Code

public function getDefaultToolkit() {
  $toolkit_id = config('system.image')
    ->get('toolkit');
  $toolkits = $this
    ->getAvailableToolkits();
  if (!isset($toolkits[$toolkit_id]) || !class_exists($toolkits[$toolkit_id]['class'])) {

    // The selected toolkit isn't available so return the first one found. If
    // none are available this will return FALSE.
    reset($toolkits);
    $toolkit_id = key($toolkits);
  }
  if ($toolkit_id) {
    $toolkit = $this
      ->createInstance($toolkit_id);
  }
  else {
    $toolkit = FALSE;
  }
  return $toolkit;
}