5 * Install, update and uninstall functions for the ImageWidgetCrop module.
9 * Implements hook_requirements().
11 function image_widget_crop_requirements($phase) {
13 $config = \Drupal::config('image_widget_crop.settings');
15 'js' => $config->get('settings.library_url'),
16 'css' => $config->get('settings.css_url')
19 foreach ($files as $type => $file) {
20 $is_local = parse_url($file, PHP_URL_SCHEME) === NULL && strpos($file, '//') !== 0;
21 // If libraries module is active check if folder is malformed.
23 && \Drupal::moduleHandler()->moduleExists('libraries')
24 && ($info = libraries_detect('cropper'))
25 && (!file_exists($info['library path'] . '/dist/cropper.min.' . $type) && !file_exists($info['library path'] . '/cropper.min.' . $type))) {
26 $error[] = t("<strong>:type</strong> file : Libraries module is active but an error detected with your cropper libraries configuration. To use cropper library with <i>'libraries'</i> module you must have the following structure <i>`:libraries_cropper`</i>", [
27 ':type' => strtoupper($type),
28 ':libraries_cropper' => '/libraries/cropper/dist/cropper.min.' . $type
34 $requirements['iwc_libraries'] = [
35 'title' => t('ImageWidgetCrop library'),
36 'value' => empty($error) ? t('Correctly configured') : t('Files not found'),
40 $requirements['iwc_libraries']['severity'] = REQUIREMENT_ERROR;
41 $requirements['iwc_libraries']['description'][] = [
42 '#theme' => 'item_list',
47 $requirements['iwc_libraries']['severity'] = REQUIREMENT_OK;
48 $requirements['iwc_libraries']['description'] = t('ImageWidgetCrop libraries files are correctly configured to use <strong>:library</strong> files', [
49 ':library' => !$is_local ? 'CDN' : 'Libraries API',