diff core/modules/image/image.install @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
line wrap: on
line diff
--- a/core/modules/image/image.install	Thu Feb 28 13:11:55 2019 +0000
+++ b/core/modules/image/image.install	Thu May 09 15:34:47 2019 +0100
@@ -5,13 +5,16 @@
  * 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() {
   // Create the styles directory and ensure it's writable.
   $directory = file_default_scheme() . '://styles';
-  file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+  \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
 }
 
 /**
@@ -19,7 +22,14 @@
  */
 function image_uninstall() {
   // Remove the styles directory and generated images.
-  file_unmanaged_delete_recursive(file_default_scheme() . '://styles');
+  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
+  $file_system = \Drupal::service('file_system');
+  try {
+    $file_system->deleteRecursive(file_default_scheme() . '://styles');
+  }
+  catch (FileException $e) {
+    // Ignore failed deletes.
+  }
 }
 
 /**