Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / image / image.install
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for the image module.
6  */
7
8 /**
9  * Implements hook_install().
10  */
11 function image_install() {
12   // Create the styles directory and ensure it's writable.
13   $directory = file_default_scheme() . '://styles';
14   file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
15 }
16
17 /**
18  * Implements hook_uninstall().
19  */
20 function image_uninstall() {
21   // Remove the styles directory and generated images.
22   file_unmanaged_delete_recursive(file_default_scheme() . '://styles');
23 }
24
25 /**
26  * Implements hook_requirements() to check the PHP GD Library.
27  *
28  * @param $phase
29  */
30 function image_requirements($phase) {
31   if ($phase != 'runtime') {
32     return [];
33   }
34
35   $toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit();
36   if ($toolkit) {
37     $plugin_definition = $toolkit->getPluginDefinition();
38     $requirements = [
39       'image.toolkit' => [
40         'title' => t('Image toolkit'),
41         'value' => $toolkit->getPluginId(),
42         'description' => $plugin_definition['title'],
43       ],
44     ];
45
46     foreach ($toolkit->getRequirements() as $key => $requirement) {
47       $namespaced_key = 'image.toolkit.' . $toolkit->getPluginId() . '.' . $key;
48       $requirements[$namespaced_key] = $requirement;
49     }
50   }
51   else {
52     $requirements = [
53       'image.toolkit' => [
54         'title' => t('Image toolkit'),
55         'value' => t('None'),
56         'description' => t("No image toolkit is configured on the site. Check PHP installed extensions or add a contributed toolkit that doesn't require a PHP extension. Make sure that at least one valid image toolkit is enabled."),
57         'severity' => REQUIREMENT_ERROR,
58       ],
59     ];
60   }
61
62   return $requirements;
63 }
64
65 /**
66  * Flush caches as we changed field formatter metadata.
67  */
68 function image_update_8201() {
69   // Empty update to trigger a cache flush.
70 }