blob: b99e17924ef6169c5a56c3964acafccb9bebc0cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
<?php
/**
* @file
* Install, update and uninstall functions for the image module.
*/
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
/**
* Implements hook_install().
*/
function image_install(): void {
// Create the styles directory and ensure it's writable.
$directory = \Drupal::config('system.file')->get('default_scheme') . '://styles';
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
/**
* Implements hook_uninstall().
*/
function image_uninstall(): void {
// Remove the styles directory and generated images.
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
try {
$file_system->deleteRecursive(\Drupal::config('system.file')->get('default_scheme') . '://styles');
}
catch (FileException) {
// Ignore failed deletes.
}
}
/**
* Implements hook_requirements().
*/
function image_requirements($phase): array {
if ($phase != 'runtime') {
return [];
}
$toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit();
if ($toolkit) {
$plugin_definition = $toolkit->getPluginDefinition();
$requirements = [
'image.toolkit' => [
'title' => t('Image toolkit'),
'value' => $toolkit->getPluginId(),
'description' => $plugin_definition['title'],
],
];
foreach ($toolkit->getRequirements() as $key => $requirement) {
$namespaced_key = 'image.toolkit.' . $toolkit->getPluginId() . '.' . $key;
$requirements[$namespaced_key] = $requirement;
}
}
else {
$requirements = [
'image.toolkit' => [
'title' => t('Image toolkit'),
'value' => t('None'),
'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 installed."),
'severity' => REQUIREMENT_ERROR,
],
];
}
return $requirements;
}
/**
* Implements hook_update_last_removed().
*/
function image_update_last_removed(): int {
return 8201;
}
|