Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / media_entity / media_entity.install
1 <?php
2
3 /**
4  * @file
5  * Install, uninstall and update hooks for Media entity module.
6  */
7
8 /**
9  * Checks if required version of the Entity API is installed.
10  *
11  * @return bool
12  *   TRUE if dependency is met and FALSE if not.
13  */
14 function _media_entity_check_entity_version() {
15   if (\Drupal::moduleHandler()->moduleExists('entity')) {
16     $info = system_get_info('module', 'entity');
17     if (version_compare($info['version'], '8.x-1.0-alpha3') >= 0) {
18       return TRUE;
19     }
20   }
21
22   return FALSE;
23 }
24
25 /**
26  * Implements hook_requirements().
27  */
28 function media_entity_requirements($phase) {
29   $requirements = [];
30   if ($phase == 'update' && !_media_entity_check_entity_version()) {
31     $requirements['entity'] = [
32       'title' => t('Media entity'),
33       'value' => t('Entity API missing'),
34       'description' => t(
35         '<a href=":url">Entity API >= 8.x-1.0-alpha3</a> module is now a dependency and needs to be installed before running updates.',
36         [':url' => 'https://www.drupal.org/project/entity']
37       ),
38       'severity' => REQUIREMENT_ERROR,
39     ];
40   }
41   return $requirements;
42 }
43
44 /**
45  * Implements hook_install().
46  */
47 function media_entity_install() {
48   $source = drupal_get_path('module', 'media_entity') . '/images/icons';
49   $destination = \Drupal::config('media_entity.settings')->get('icon_base');
50   media_entity_copy_icons($source, $destination);
51 }
52
53 /**
54  * Remove "type" base field.
55  */
56 function media_entity_update_8001() {
57   $fields = \Drupal::database()->query('DESCRIBE {media_field_data}')->fetchCol();
58   if (in_array('type', $fields)) {
59     \Drupal::database()->update('media_field_data')
60       ->fields(['type' => NULL])
61       ->execute();
62   }
63
64   $manager = \Drupal::entityDefinitionUpdateManager();
65   if ($field = $manager->getFieldStorageDefinition('type', 'media')) {
66     $manager->uninstallFieldStorageDefinition($field);
67   }
68 }
69
70 /**
71  * Ensure media entity status value (defaulting to 1).
72  */
73 function media_entity_update_8002() {
74   // Ensure status values in 'media_field_data' table.
75   if (\Drupal::database()->schema()->tableExists('media_field_data')) {
76     \Drupal::database()
77       ->update('media_field_data')
78       ->fields(['status' => 1])
79       ->condition('status', NULL, 'IS NULL')
80       ->execute();
81   }
82
83   // Ensure status values in 'media_field_revision' table.
84   if (\Drupal::database()->schema()->tableExists('media_field_revision')) {
85     \Drupal::database()
86       ->update('media_field_revision')
87       ->fields(['status' => 1])
88       ->condition('status', NULL, 'IS NULL')
89       ->execute();
90   }
91
92   // Flush all caches.
93   drupal_flush_all_caches();
94 }
95
96 /**
97  * Ensure Entity API is installed.
98  */
99 function media_entity_update_8003() {
100   if (!_media_entity_check_entity_version()) {
101     throw new \Drupal\Core\Utility\UpdateException('Entity API >= 8.x-1.0-alpha3 (drupal.org/project/entity) module is now a dependency and needs to be installed before running updates.');
102   }
103 }