Chris@0: prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_uninstall(). Chris@0: */ Chris@0: function image_uninstall() { Chris@0: // Remove the styles directory and generated images. Chris@18: /** @var \Drupal\Core\File\FileSystemInterface $file_system */ Chris@18: $file_system = \Drupal::service('file_system'); Chris@18: try { Chris@18: $file_system->deleteRecursive(file_default_scheme() . '://styles'); Chris@18: } Chris@18: catch (FileException $e) { Chris@18: // Ignore failed deletes. Chris@18: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_requirements() to check the PHP GD Library. Chris@0: * Chris@0: * @param $phase Chris@0: */ Chris@0: function image_requirements($phase) { Chris@0: if ($phase != 'runtime') { Chris@0: return []; Chris@0: } Chris@0: Chris@0: $toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit(); Chris@0: if ($toolkit) { Chris@0: $plugin_definition = $toolkit->getPluginDefinition(); Chris@0: $requirements = [ Chris@0: 'image.toolkit' => [ Chris@0: 'title' => t('Image toolkit'), Chris@0: 'value' => $toolkit->getPluginId(), Chris@0: 'description' => $plugin_definition['title'], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: foreach ($toolkit->getRequirements() as $key => $requirement) { Chris@0: $namespaced_key = 'image.toolkit.' . $toolkit->getPluginId() . '.' . $key; Chris@0: $requirements[$namespaced_key] = $requirement; Chris@0: } Chris@0: } Chris@0: else { Chris@0: $requirements = [ Chris@0: 'image.toolkit' => [ Chris@0: 'title' => t('Image toolkit'), Chris@0: 'value' => t('None'), Chris@0: '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."), Chris@0: 'severity' => REQUIREMENT_ERROR, Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: Chris@0: return $requirements; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Flush caches as we changed field formatter metadata. Chris@0: */ Chris@0: function image_update_8201() { Chris@0: // Empty update to trigger a cache flush. Chris@17: Chris@17: // Use hook_post_update_NAME() instead to clear the cache. The use of Chris@17: // hook_update_N() to clear the cache has been deprecated see Chris@17: // https://www.drupal.org/node/2960601 for more details. Chris@0: }