Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / image_widget_crop / image_widget_crop.install
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for the ImageWidgetCrop module.
6  */
7
8 /**
9  * Implements hook_requirements().
10  */
11 function image_widget_crop_requirements($phase) {
12   $error = [];
13   $config = \Drupal::config('image_widget_crop.settings');
14   $files = [
15     'js' => $config->get('settings.library_url'),
16     'css' => $config->get('settings.css_url')
17   ];
18
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.
22     if ($is_local
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
29         ]);
30     }
31   }
32
33   $requirements = [];
34   $requirements['iwc_libraries'] = [
35     'title' => t('ImageWidgetCrop library'),
36     'value' => empty($error) ? t('Correctly configured') : t('Files not found'),
37   ];
38
39   if (!empty($error)) {
40     $requirements['iwc_libraries']['severity'] = REQUIREMENT_ERROR;
41     $requirements['iwc_libraries']['description'][] = [
42       '#theme' => 'item_list',
43       '#items' => $error,
44     ];
45   }
46   else {
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',
50     ]);
51   }
52   return $requirements;
53 }