Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / crop / crop.install
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for the Crop API module.
6  */
7
8 use Drupal\crop\Entity\Crop;
9
10 /**
11  * Delete orphaned crop entities.
12  */
13 function crop_update_8001(&$sandbox) {
14   // Unsure we have current element set to 0.
15   if (!isset($sandbox['current'])) {
16     $sandbox['current'] = 0;
17     $sandbox['total'] = \Drupal::entityQuery('crop')
18       ->count()
19       ->execute();
20   }
21
22   $items_per_batch = 100;
23   $crops = \Drupal::entityQuery('crop')
24     ->sort('cid', 'ASC')
25     ->range($sandbox['current'], $items_per_batch)
26     ->execute();
27
28   if (empty($crops)) {
29     $sandbox['#finished'] = 1;
30   }
31   else {
32     foreach ($crops as $cid) {
33       /** @var \Drupal\crop\Entity\Crop $crop */
34       $crop = Crop::load($cid);
35       $files = \Drupal::entityQuery('file')
36         ->condition('uri', $crop->get('uri')->value)
37         ->count();
38
39       // Checks if the file exist, if not exist delete this orphan crop.
40       if (empty($files->execute())) {
41         // Lets tell the site admin what we are doing.
42         \Drupal::logger('crop_api')
43           ->notice(
44             'The orphaned crop @cid referring to image with URI @uri has been deleted.',
45             ['@cid' => $cid, 'uri' => $crop->uri->value]
46           );
47         $crop->delete();
48       }
49       $sandbox['current']++;
50     }
51     $sandbox['#finished'] = $sandbox['current'] / $sandbox['total'];
52   }
53 }
54
55 /**
56  * Let Drupal know that there is a new config available.
57  */
58 function crop_update_8002() {
59   \Drupal::service('config.installer')
60     ->installDefaultConfig('module', 'crop');
61 }