diff --git a/core/includes/file.inc b/core/includes/file.inc
index af5e6d8f9b..e858cc9ebd 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -47,7 +47,7 @@
* Flag used to create a directory if not present.
*
* @deprecated in Drupal 8.7.0, will be removed before Drupal 9.0.0.
- * Use \Drupal\Core\File\FileSystemInterface::FILE_CREATE_DIRECTORY.
+ * Use \Drupal\Core\File\FileSystemInterface::CREATE_DIRECTORY.
*/
const FILE_CREATE_DIRECTORY = FileSystemInterface::CREATE_DIRECTORY;
@@ -55,7 +55,7 @@
* Flag used to indicate file permissions may be changed.
*
* @deprecated in Drupal 8.7.0, will be removed before Drupal 9.0.0.
- * Use \Drupal\Core\File\FileSystemInterface::FILE_MODIFY_PERMISSIONS.
+ * Use \Drupal\Core\File\FileSystemInterface::MODIFY_PERMISSIONS.
*/
const FILE_MODIFY_PERMISSIONS = FileSystemInterface::MODIFY_PERMISSIONS;
@@ -63,7 +63,7 @@
* Flag for dealing with existing files: Appends number until name is unique.
*
* @deprecated in Drupal 8.7.0, will be removed before Drupal 9.0.0.
- * Use \Drupal\Core\File\FileSystemInterface::FILE_EXISTS_RENAME.
+ * Use \Drupal\Core\File\FileSystemInterface::EXISTS_RENAME.
*/
const FILE_EXISTS_RENAME = FileSystemInterface::EXISTS_RENAME;
@@ -71,7 +71,7 @@
* Flag for dealing with existing files: Replace the existing file.
*
* @deprecated in Drupal 8.7.0, will be removed before Drupal 9.0.0.
- * Use \Drupal\Core\File\FileSystemInterface::FILE_EXISTS_REPLACE.
+ * Use \Drupal\Core\File\FileSystemInterface::EXISTS_REPLACE.
*/
const FILE_EXISTS_REPLACE = FileSystemInterface::EXISTS_REPLACE;
@@ -79,7 +79,7 @@
* Flag for dealing with existing files: Do nothing and return FALSE.
*
* @deprecated in Drupal 8.7.0, will be removed before Drupal 9.0.0.
- * Use \Drupal\Core\File\FileSystemInterface::FILE_EXISTS_ERROR.
+ * Use \Drupal\Core\File\FileSystemInterface::EXISTS_ERROR.
*/
const FILE_EXISTS_ERROR = FileSystemInterface::EXISTS_ERROR;
diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php
index 49a1d6e2c1..e30230b407 100644
--- a/core/lib/Drupal/Core/Extension/module.api.php
+++ b/core/lib/Drupal/Core/Extension/module.api.php
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Database\Database;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Url;
use Drupal\Core\Utility\UpdateException;
@@ -226,7 +227,7 @@ function hook_modules_installed($modules) {
function hook_install() {
// Create the styles directory and ensure it's writable.
$directory = file_default_scheme() . '://styles';
- \Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY | FileSystemInterface::FILE_MODIFY_PERMISSIONS);
+ \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
/**
diff --git a/core/lib/Drupal/Core/File/FileSystem.php b/core/lib/Drupal/Core/File/FileSystem.php
index f84988608d..56b42439f9 100644
--- a/core/lib/Drupal/Core/File/FileSystem.php
+++ b/core/lib/Drupal/Core/File/FileSystem.php
@@ -545,7 +545,7 @@ public function saveData($data, $destination = NULL, $replace = self::EXISTS_REN
/**
* {@inheritdoc}
*/
- public function prepareDirectory(&$directory, $options = FileSystemInterface::MODIFY_PERMISSIONS) {
+ public function prepareDirectory(&$directory, $options = self::MODIFY_PERMISSIONS) {
if (!$this->validScheme($this->uriScheme($directory))) {
// Only trim if we're not dealing with a stream.
$directory = rtrim($directory, '/\\');
diff --git a/core/lib/Drupal/Core/File/FileSystemInterface.php b/core/lib/Drupal/Core/File/FileSystemInterface.php
index 1aa1374a05..c35ff2c26e 100644
--- a/core/lib/Drupal/Core/File/FileSystemInterface.php
+++ b/core/lib/Drupal/Core/File/FileSystemInterface.php
@@ -416,14 +416,14 @@ public function saveData($data, $destination = NULL, $replace = self::EXISTS_REN
* trailing slash will be trimmed from a path.
* @param int $options
* A bitmask to indicate if the directory should be created if it does
- * not exist (FILE_CREATE_DIRECTORY) or made writable if it is read-only
- * (FILE_MODIFY_PERMISSIONS).
+ * not exist (FileSystemInterface::CREATE_DIRECTORY) or made writable if it
+ * is read-only (FileSystemInterface::MODIFY_PERMISSIONS).
*
* @return bool
* TRUE if the directory exists (or was created) and is writable. FALSE
* otherwise.
*/
- public function prepareDirectory(&$directory, $options = FileSystemInterface::MODIFY_PERMISSIONS);
+ public function prepareDirectory(&$directory, $options = self::MODIFY_PERMISSIONS);
/**
* Creates a full file path from a directory and filename.
@@ -449,14 +449,14 @@ public function createFilename($basename, $directory);
* The desired final URI or filepath.
* @param int $replace
* Replace behavior when the destination file already exists.
- * - FILE_EXISTS_REPLACE - Replace the existing file.
- * - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename
- * is unique.
- * - FILE_EXISTS_ERROR - Do nothing and return FALSE.
+ * - FileSystemInterface::EXISTS_REPLACE - Replace the existing file.
+ * - FileSystemInterface::EXISTS_RENAME - Append _{incrementing number}
+ * until the filename is unique.
+ * - FileSystemInterface::EXISTS_ERROR - Do nothing and return FALSE.
*
* @return string|bool
* The destination filepath, or FALSE if the file already exists
- * and FILE_EXISTS_ERROR is specified.
+ * and FileSystemInterface::EXISTS_ERROR is specified.
*/
public function getDestinationFilename($destination, $replace);
diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
index 6b196d46f6..0ec3388fec 100644
--- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
@@ -319,7 +319,7 @@ protected function initConfig(ContainerInterface $container) {
$config = $container->get('config.factory');
// Manually create the private directory.
- \Drupal::service('file_system')->prepareDirectory($this->privateFilesDirectory, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($this->privateFilesDirectory, FileSystemInterface::CREATE_DIRECTORY);
// Manually configure the test mail collector implementation to prevent
// tests from sending out emails and collect them in state instead.
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index 17559fabaf..0a1f4b06e7 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -11,6 +11,7 @@
use Drupal\Component\Utility\Environment;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Cache\CacheableMetadata;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Render\Element\Textfield;
@@ -441,7 +442,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
$paths['color'] = 'public://color';
$paths['target'] = $paths['color'] . '/' . $id;
foreach ($paths as $path) {
- \Drupal::service('file_system')->prepareDirectory($path, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
}
$paths['target'] = $paths['target'] . '/';
$paths['id'] = $id;
diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
index 13241e07b4..202a96682b 100644
--- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
+++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
@@ -8,6 +8,7 @@
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\TypedData\DataDefinition;
@@ -325,12 +326,12 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin
// Prepare destination.
$dirname = static::doGetUploadLocation($settings);
- \Drupal::service('file_system')->prepareDirectory($dirname, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($dirname, FileSystemInterface::CREATE_DIRECTORY);
// Generate a file entity.
$destination = $dirname . '/' . $random->name(10, TRUE) . '.txt';
$data = $random->paragraphs(3);
- $file = file_save_data($data, $destination, FILE_EXISTS_ERROR);
+ $file = file_save_data($data, $destination, FileSystemInterface::EXISTS_ERROR);
$values = [
'target_id' => $file->id(),
'display' => (int) $settings['display_default'],
diff --git a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
index 16530ed1fa..5cffdab0cc 100644
--- a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
+++ b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
@@ -226,7 +226,7 @@ public function post(Request $request, $entity_type_id, $bundle, $field_name) {
$destination = $this->getUploadLocation($field_definition->getSettings());
// Check the destination file path is writable.
- if (!\Drupal::service('file_system')->prepareDirectory($destination, FILE_CREATE_DIRECTORY)) {
+ if (!\Drupal::service('file_system')->prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY)) {
throw new HttpException(500, 'Destination file path is not writable');
}
diff --git a/core/modules/file/tests/file_test/src/Form/FileTestForm.php b/core/modules/file/tests/file_test/src/Form/FileTestForm.php
index 1678739b7a..7234c00864 100644
--- a/core/modules/file/tests/file_test/src/Form/FileTestForm.php
+++ b/core/modules/file/tests/file_test/src/Form/FileTestForm.php
@@ -2,6 +2,7 @@
namespace Drupal\file_test\Form;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
@@ -29,11 +30,11 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'select',
'#title' => t('Replace existing image'),
'#options' => [
- FILE_EXISTS_RENAME => t('Appends number until name is unique'),
- FILE_EXISTS_REPLACE => t('Replace the existing file'),
- FILE_EXISTS_ERROR => t('Fail with an error'),
+ FileSystemInterface::EXISTS_RENAME => t('Appends number until name is unique'),
+ FileSystemInterface::EXISTS_REPLACE => t('Replace the existing file'),
+ FileSystemInterface::EXISTS_ERROR => t('Fail with an error'),
],
- '#default_value' => FILE_EXISTS_RENAME,
+ '#default_value' => FileSystemInterface::EXISTS_RENAME,
];
$form['file_subdir'] = [
'#type' => 'textfield',
@@ -79,7 +80,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// form value for the $replace parameter.
if (!$form_state->isValueEmpty('file_subdir')) {
$destination = 'temporary://' . $form_state->getValue('file_subdir');
- \Drupal::service('file_system')->prepareDirectory($destination, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY);
}
else {
$destination = FALSE;
diff --git a/core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php b/core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php
index 3e7dccd38c..ba87e6b908 100644
--- a/core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php
+++ b/core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php
@@ -2,6 +2,7 @@
namespace Drupal\file_test\Form;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
@@ -70,11 +71,11 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'select',
'#title' => $this->t('Replace existing image'),
'#options' => [
- FILE_EXISTS_RENAME => $this->t('Appends number until name is unique'),
- FILE_EXISTS_REPLACE => $this->t('Replace the existing file'),
- FILE_EXISTS_ERROR => $this->t('Fail with an error'),
+ FileSystemInterface::EXISTS_RENAME => $this->t('Appends number until name is unique'),
+ FileSystemInterface::EXISTS_REPLACE => $this->t('Replace the existing file'),
+ FileSystemInterface::EXISTS_ERROR => $this->t('Fail with an error'),
],
- '#default_value' => FILE_EXISTS_RENAME,
+ '#default_value' => FileSystemInterface::EXISTS_RENAME,
];
$form['file_subdir'] = [
'#type' => 'textfield',
@@ -121,7 +122,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
// form value for the $replace parameter.
if (!$form_state->isValueEmpty('file_subdir')) {
$destination = 'temporary://' . $form_state->getValue('file_subdir');
- \Drupal::service('file_system')->prepareDirectory($destination, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY);
}
else {
$destination = FALSE;
diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php
index 66a0307a7a..bf25a44cad 100644
--- a/core/modules/file/tests/src/Functional/DownloadTest.php
+++ b/core/modules/file/tests/src/Functional/DownloadTest.php
@@ -2,6 +2,8 @@
namespace Drupal\Tests\file\Functional;
+use Drupal\Core\File\FileSystemInterface;
+
/**
* Tests for download/file transfer functions.
*
@@ -145,7 +147,7 @@ private function checkUrl($scheme, $directory, $filename, $expected_url) {
// directory.
$filepath = \Drupal::service('file_system')->createFilename($filename, $directory);
$directory_uri = $scheme . '://' . dirname($filepath);
- \Drupal::service('file_system')->prepareDirectory($directory_uri, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($directory_uri, FileSystemInterface::CREATE_DIRECTORY);
$file = $this->createFile($filepath, NULL, $scheme);
$url = file_create_url($file->getFileUri());
diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
index 2a43a9997f..a9b3aca204 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
@@ -2,6 +2,7 @@
namespace Drupal\Tests\file\Functional;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\file\Entity\File;
use Drupal\Tests\TestFileCreationTrait;
@@ -302,7 +303,7 @@ public function testExistingRename() {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$edit = [
- 'file_test_replace' => FILE_EXISTS_RENAME,
+ 'file_test_replace' => FileSystemInterface::EXISTS_RENAME,
'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
diff --git a/core/modules/file/tests/src/Functional/SaveUploadTest.php b/core/modules/file/tests/src/Functional/SaveUploadTest.php
index 552cfc628e..0e3d6da488 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php
@@ -2,6 +2,7 @@
namespace Drupal\Tests\file\Functional;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\file\Entity\File;
use Drupal\Tests\TestFileCreationTrait;
@@ -285,7 +286,7 @@ public function testHandleFileMunge() {
*/
public function testExistingRename() {
$edit = [
- 'file_test_replace' => FILE_EXISTS_RENAME,
+ 'file_test_replace' => FileSystemInterface::EXISTS_RENAME,
'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
diff --git a/core/modules/file/tests/src/Kernel/CopyTest.php b/core/modules/file/tests/src/Kernel/CopyTest.php
index 7ba92f8332..26cb2f98ce 100644
--- a/core/modules/file/tests/src/Kernel/CopyTest.php
+++ b/core/modules/file/tests/src/Kernel/CopyTest.php
@@ -54,7 +54,7 @@ public function testExistingRename() {
// Clone the object so we don't have to worry about the function changing
// our reference copy.
- $result = file_copy(clone $source, $target->getFileUri(), FILE_EXISTS_RENAME);
+ $result = file_copy(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_RENAME);
// Check the return status and that the contents changed.
$this->assertTrue($result, 'File copied successfully.');
diff --git a/core/modules/file/tests/src/Kernel/MoveTest.php b/core/modules/file/tests/src/Kernel/MoveTest.php
index bbc3bb2fb9..59c93ca4f3 100644
--- a/core/modules/file/tests/src/Kernel/MoveTest.php
+++ b/core/modules/file/tests/src/Kernel/MoveTest.php
@@ -4,6 +4,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\Exception\FileExistsException;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\file\Entity\File;
/**
@@ -55,7 +56,7 @@ public function testExistingRename() {
// Clone the object so we don't have to worry about the function changing
// our reference copy.
- $result = file_move(clone $source, $target->getFileUri(), FILE_EXISTS_RENAME);
+ $result = file_move(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_RENAME);
// Check the return status and that the contents changed.
$this->assertTrue($result, 'File moved successfully.');
diff --git a/core/modules/file/tests/src/Kernel/SaveDataTest.php b/core/modules/file/tests/src/Kernel/SaveDataTest.php
index a37e4dfce9..3841537bbf 100644
--- a/core/modules/file/tests/src/Kernel/SaveDataTest.php
+++ b/core/modules/file/tests/src/Kernel/SaveDataTest.php
@@ -3,6 +3,7 @@
namespace Drupal\Tests\file\Kernel;
use Drupal\Core\File\Exception\FileExistsException;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\file\Entity\File;
/**
@@ -67,7 +68,7 @@ public function testExistingRename() {
$existing = $this->createFile();
$contents = $this->randomMachineName(8);
- $result = file_save_data($contents, $existing->getFileUri(), FILE_EXISTS_RENAME);
+ $result = file_save_data($contents, $existing->getFileUri(), FileSystemInterface::EXISTS_RENAME);
$this->assertTrue($result, 'File saved successfully.');
$this->assertEqual('public', file_uri_scheme($result->getFileUri()), "File was placed in Drupal's files directory.");
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 0849077676..34e38a5649 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\file\FileInterface;
use Drupal\field\FieldStorageConfigInterface;
@@ -434,7 +435,7 @@ function image_field_storage_config_update(FieldStorageConfigInterface $field_st
// If the upload destination changed, then move the file.
if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field_storage->getSetting('uri_scheme'))) {
$directory = $field_storage->getSetting('uri_scheme') . '://default_images/';
- \Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
file_move($file_new, $directory . $file_new->getFilename());
}
}
@@ -472,7 +473,7 @@ function image_field_config_update(FieldConfigInterface $field) {
// If the upload destination changed, then move the file.
if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field_storage->getSetting('uri_scheme'))) {
$directory = $field_storage->getSetting('uri_scheme') . '://default_images/';
- \Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
file_move($file_new, $directory . $file_new->getFilename());
}
}
diff --git a/core/modules/image/src/Controller/QuickEditImageController.php b/core/modules/image/src/Controller/QuickEditImageController.php
index 383e18e769..7e2a56d72a 100644
--- a/core/modules/image/src/Controller/QuickEditImageController.php
+++ b/core/modules/image/src/Controller/QuickEditImageController.php
@@ -6,6 +6,7 @@
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Image\ImageFactory;
use Drupal\Core\Render\Element\StatusMessages;
use Drupal\Core\Render\RendererInterface;
@@ -95,7 +96,7 @@ public function upload(EntityInterface $entity, $field_name, $langcode, $view_mo
}
// Create the destination directory if it does not already exist.
- if (isset($destination) && !\Drupal::service('file_system')->prepareDirectory($destination, FILE_CREATE_DIRECTORY)) {
+ if (isset($destination) && !\Drupal::service('file_system')->prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY)) {
return new JsonResponse(['main_error' => $this->t('The destination directory could not be created.'), 'errors' => '']);
}
diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
index acde58a27f..06770965ac 100644
--- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
+++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
@@ -6,6 +6,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\TypedData\DataDefinition;
@@ -352,7 +353,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin
$image->setMimeType(\Drupal::service('file.mime_type.guesser')->guess($path));
$image->setFileName(drupal_basename($path));
$destination_dir = static::doGetUploadLocation($settings);
- \Drupal::service('file_system')->prepareDirectory($destination_dir, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($destination_dir, FileSystemInterface::CREATE_DIRECTORY);
$destination = $destination_dir . '/' . basename($path);
$file = file_move($image, $destination);
$images[$extension][$min_resolution][$max_resolution][$file->id()] = $file;
diff --git a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
index 1530b56c9f..4c80bb1774 100644
--- a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
+++ b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
@@ -2,6 +2,7 @@
namespace Drupal\Tests\image\Functional;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\image\Entity\ImageStyle;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\TestFileCreationTrait;
@@ -35,13 +36,15 @@ public function testImageDimensions() {
// Create a working copy of the file.
$files = $this->drupalGetTestFiles('image');
$file = reset($files);
- $original_uri = \Drupal::service('file_system')->copy($file->uri, 'public://', FILE_EXISTS_RENAME);
+ /** @var \Drupal\Core\File\FileSystemInterface $file_system */
+ $file_system = \Drupal::service('file_system');
+ $original_uri = $file_system->copy($file->uri, 'public://', FileSystemInterface::EXISTS_RENAME);
// Create a style.
/** @var $style \Drupal\image\ImageStyleInterface */
$style = ImageStyle::create(['name' => 'test', 'label' => 'Test']);
$style->save();
- $generated_uri = 'public://styles/test/public/' . \Drupal::service('file_system')->basename($original_uri);
+ $generated_uri = 'public://styles/test/public/' . $file_system->basename($original_uri);
$url = file_url_transform_relative($style->buildUrl($original_uri));
$variables = [
@@ -257,7 +260,7 @@ public function testImageDimensions() {
'#height' => 20,
];
// PNG original image. Should be resized to 100x100.
- $generated_uri = 'public://styles/test_uri/public/' . \Drupal::service('file_system')->basename($original_uri);
+ $generated_uri = 'public://styles/test_uri/public/' . $file_system->basename($original_uri);
$url = file_url_transform_relative($style->buildUrl($original_uri));
$this->assertEqual($this->getImageTag($variables), '
');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
@@ -269,8 +272,8 @@ public function testImageDimensions() {
$this->assertEqual($image_file->getHeight(), 100);
// GIF original image. Should be resized to 50x50.
$file = $files[1];
- $original_uri = \Drupal::service('file_system')->copy($file->uri, 'public://', FILE_EXISTS_RENAME);
- $generated_uri = 'public://styles/test_uri/public/' . \Drupal::service('file_system')->basename($original_uri);
+ $original_uri = $file_system->copy($file->uri, 'public://', FileSystemInterface::EXISTS_RENAME);
+ $generated_uri = 'public://styles/test_uri/public/' . $file_system->basename($original_uri);
$url = file_url_transform_relative($style->buildUrl($original_uri));
$variables['#uri'] = $original_uri;
$this->assertEqual($this->getImageTag($variables), '
');
diff --git a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php
index 90b9b43743..69cb5d8c78 100644
--- a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php
+++ b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php
@@ -2,6 +2,7 @@
namespace Drupal\Tests\image\Functional;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\image\Entity\ImageStyle;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
@@ -134,7 +135,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s
// Create the directories for the styles.
$directory = $scheme . '://styles/' . $this->style->id();
- $status = \Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY);
+ $status = \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
$this->assertNotIdentical(FALSE, $status, 'Created the directory for the generated images for the test style.');
// Override the language to build the URL for the correct language.
@@ -149,7 +150,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s
$file = array_shift($files);
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
- $original_uri = $file_system->copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME);
+ $original_uri = $file_system->copy($file->uri, $scheme . '://', FileSystemInterface::EXISTS_RENAME);
// Let the image_module_test module know about this file, so it can claim
// ownership in hook_file_download().
\Drupal::state()->set('image.test_file_download', $original_uri);
@@ -233,7 +234,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s
// Repeat this with a different file that we do not have access to and
// make sure that access is denied.
$file_noaccess = array_shift($files);
- $original_uri_noaccess = $file_system->copy($file_noaccess->uri, $scheme . '://', FILE_EXISTS_RENAME);
+ $original_uri_noaccess = $file_system->copy($file_noaccess->uri, $scheme . '://', FileSystemInterface::EXISTS_RENAME);
$generated_uri_noaccess = $scheme . '://styles/' . $this->style->id() . '/' . $scheme . '/' . drupal_basename($original_uri_noaccess);
$this->assertFalse(file_exists($generated_uri_noaccess), 'Generated file does not exist.');
$generate_url_noaccess = $this->style->buildUrl($original_uri_noaccess);
@@ -273,7 +274,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s
// Create another working copy of the file.
$files = $this->drupalGetTestFiles('image');
$file = array_shift($files);
- $original_uri = $file_system->copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME);
+ $original_uri = $file_system->copy($file->uri, $scheme . '://', FileSystemInterface::EXISTS_RENAME);
// Let the image_module_test module know about this file, so it can claim
// ownership in hook_file_download().
\Drupal::state()->set('image.test_file_download', $original_uri);
diff --git a/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php b/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php
index eaa9ecee76..8a1c2c6e74 100644
--- a/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php
+++ b/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php
@@ -3,6 +3,7 @@
namespace Drupal\Tests\image\Kernel;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
@@ -80,7 +81,7 @@ public function testImageFormatterTheme() {
// Create an image.
$files = $this->drupalGetTestFiles('image');
$file = reset($files);
- $original_uri = \Drupal::service('file_system')->copy($file->uri, 'public://', FILE_EXISTS_RENAME);
+ $original_uri = \Drupal::service('file_system')->copy($file->uri, 'public://', FileSystemInterface::EXISTS_RENAME);
// Create a style.
$style = ImageStyle::create(['name' => 'test', 'label' => 'Test']);
@@ -142,7 +143,7 @@ public function testImageStyleTheme() {
// Create an image.
$files = $this->drupalGetTestFiles('image');
$file = reset($files);
- $original_uri = \Drupal::service('file_system')->copy($file->uri, 'public://', FILE_EXISTS_RENAME);
+ $original_uri = \Drupal::service('file_system')->copy($file->uri, 'public://', FileSystemInterface::EXISTS_RENAME);
// Create a style.
$style = ImageStyle::create(['name' => 'image_test', 'label' => 'Test']);
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index a59e52a42e..d64d313f6d 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -16,6 +16,7 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\Utility\Xss;
use Drupal\Core\File\Exception\FileException;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Url;
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Form\FormStateInterface;
@@ -1314,7 +1315,7 @@ function _locale_rebuild_js($langcode = NULL) {
$dest = $dir . '/' . $language->getId() . '_' . $data_hash . '.js';
if ($data && ($changed_hash || !file_exists($dest))) {
// Ensure that the directory exists and is writable, if possible.
- \Drupal::service('file_system')->prepareDirectory($dir, FILE_CREATE_DIRECTORY);
+ $file_system->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY);
// Save the file.
try {
diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php b/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php
index a961cb3df5..63ca5e762e 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php
@@ -3,6 +3,7 @@
namespace Drupal\Tests\locale\Functional;
use Drupal\Core\Database\Database;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\file\Entity\File;
use Drupal\Tests\BrowserTestBase;
@@ -76,7 +77,7 @@ protected function setUp() {
* directory.
*/
protected function setTranslationsDirectory($path) {
- \Drupal::service('file_system')->prepareDirectory($path, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
$this->config('locale.settings')->set('translation.path', $path)->save();
}
@@ -130,7 +131,7 @@ protected function makePoFile($path, $filename, $timestamp = NULL, array $transl
}
}
- \Drupal::service('file_system')->prepareDirectory($path, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
$file = File::create([
'uid' => 1,
'filename' => $filename,
diff --git a/core/modules/media_library/src/Form/MediaLibraryUploadForm.php b/core/modules/media_library/src/Form/MediaLibraryUploadForm.php
index 19c8caed6a..db97bb78be 100644
--- a/core/modules/media_library/src/Form/MediaLibraryUploadForm.php
+++ b/core/modules/media_library/src/Form/MediaLibraryUploadForm.php
@@ -10,6 +10,7 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\TypedData\FieldItemDataDefinition;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\ElementInfoManagerInterface;
@@ -427,7 +428,7 @@ protected function createMediaEntity(FileInterface $file, MediaTypeInterface $ty
]);
$source_field = $type->getSource()->getSourceFieldDefinition($type)->getName();
$location = $this->getUploadLocationForType($media->bundle->entity);
- if (!\Drupal::service('file_system')->prepareDirectory($location, FILE_CREATE_DIRECTORY)) {
+ if (!\Drupal::service('file_system')->prepareDirectory($location, FileSystemInterface::CREATE_DIRECTORY)) {
throw new \Exception("The destination directory '$location' is not writable");
}
$file = file_move($file, $location);
diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php
index 001bfa210e..24cb637fde 100644
--- a/core/modules/simpletest/src/KernelTestBase.php
+++ b/core/modules/simpletest/src/KernelTestBase.php
@@ -288,7 +288,7 @@ protected function setUp() {
// StreamWrapper APIs.
// @todo Move StreamWrapper management into DrupalKernel.
// @see https://www.drupal.org/node/2028109
- \Drupal::service('file_system')->prepareDirectory($this->publicFilesDirectory, FILE_CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
+ \Drupal::service('file_system')->prepareDirectory($this->publicFilesDirectory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
$this->settingsSet('file_public_path', $this->publicFilesDirectory);
$this->streamWrappers = [];
$this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream');
diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php
index 27333cfe17..88b3f68fcf 100644
--- a/core/modules/simpletest/src/TestBase.php
+++ b/core/modules/simpletest/src/TestBase.php
@@ -904,7 +904,7 @@ public function run(array $methods = []) {
$this->verbose = TRUE;
$this->verboseDirectory = PublicStream::basePath() . '/simpletest/verbose';
$this->verboseDirectoryUrl = file_create_url($this->verboseDirectory);
- if (\Drupal::service('file_system')->prepareDirectory($this->verboseDirectory, FILE_CREATE_DIRECTORY) && !file_exists($this->verboseDirectory . '/.htaccess')) {
+ if (\Drupal::service('file_system')->prepareDirectory($this->verboseDirectory, FileSystemInterface::CREATE_DIRECTORY) && !file_exists($this->verboseDirectory . '/.htaccess')) {
file_put_contents($this->verboseDirectory . '/.htaccess', "\nExpiresActive Off\n\n");
}
$this->verboseClassName = str_replace("\\", "_", $class);
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 4a93a138a1..e6829e60b7 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -11,6 +11,7 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Cache\Cache;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Queue\QueueGarbageCollectionInterface;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Extension\Extension;
@@ -1330,7 +1331,7 @@ function system_time_zones($blank = NULL, $grouped = FALSE) {
* object which describes the file.
* - If it fails, FALSE.
*/
-function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME) {
+function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FileSystemInterface::EXISTS_RENAME) {
$parsed_url = parse_url($url);
if (!isset($destination)) {
$path = file_build_uri(drupal_basename($parsed_url['path']));
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index fc3fd0ffcd..3bc1378530 100644
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -1565,7 +1565,7 @@ function simpletest_script_open_browser() {
// Ensure we have assets verbose directory - tests with no verbose output will
// not have created one.
$directory = PublicStream::basePath() . '/simpletest/verbose';
- \Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY | FileSystemInterface::FILE_MODIFY_PERMISSIONS);
+ \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
$php = new Php();
$uuid = $php->generate();
$filename = $directory . '/results-' . $uuid . '.html';
diff --git a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
index 0bc08b8016..80ef82c070 100644
--- a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
@@ -60,10 +60,12 @@ public function testFileCheckDirectoryHandling() {
$this->assertFalse(is_dir($directory), 'Directory does not exist prior to testing.');
// Non-existent directory.
- $this->assertFalse(\Drupal::service('file_system')->prepareDirectory($directory, 0), 'Error reported for non-existing directory.', 'File');
+ /** @var \Drupal\Core\File\FileSystemInterface $file_system */
+ $file_system = \Drupal::service('file_system');
+ $this->assertFalse($file_system->prepareDirectory($directory, 0), 'Error reported for non-existing directory.', 'File');
// Make a directory.
- $this->assertTrue(\Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY), 'No error reported when creating a new directory.', 'File');
+ $this->assertTrue($file_system->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY), 'No error reported when creating a new directory.', 'File');
// Make sure directory actually exists.
$this->assertTrue(is_dir($directory), 'Directory actually exists.', 'File');
@@ -76,11 +78,11 @@ public function testFileCheckDirectoryHandling() {
// Make directory read only.
@drupal_chmod($directory, 0444);
- $this->assertFalse(\Drupal::service('file_system')->prepareDirectory($directory, 0), 'Error reported for a non-writeable directory.', 'File');
+ $this->assertFalse($file_system->prepareDirectory($directory, 0), 'Error reported for a non-writeable directory.', 'File');
// Test directory permission modification.
$this->setSetting('file_chmod_directory', 0777);
- $this->assertTrue(\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::MODIFY_PERMISSIONS), 'No error reported when making directory writeable.', 'File');
+ $this->assertTrue($file_system->prepareDirectory($directory, FileSystemInterface::MODIFY_PERMISSIONS), 'No error reported when making directory writeable.', 'File');
}
// Test that the directory has the correct permissions.
@@ -139,19 +141,19 @@ public function testFileDestination() {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$path = $file_system->getDestinationFilename($destination, FileSystemInterface::EXISTS_REPLACE);
- $this->assertEqual($path, $destination, 'Non-existing filepath destination is correct with FILE_EXISTS_REPLACE.', 'File');
+ $this->assertEqual($path, $destination, 'Non-existing filepath destination is correct with FileSystemInterface::EXISTS_REPLACE.', 'File');
$path = $file_system->getDestinationFilename($destination, FileSystemInterface::EXISTS_RENAME);
- $this->assertEqual($path, $destination, 'Non-existing filepath destination is correct with FILE_EXISTS_RENAME.', 'File');
+ $this->assertEqual($path, $destination, 'Non-existing filepath destination is correct with FileSystemInterface::EXISTS_RENAME.', 'File');
$path = $file_system->getDestinationFilename($destination, FileSystemInterface::EXISTS_ERROR);
- $this->assertEqual($path, $destination, 'Non-existing filepath destination is correct with FILE_EXISTS_ERROR.', 'File');
+ $this->assertEqual($path, $destination, 'Non-existing filepath destination is correct with FileSystemInterface::EXISTS_ERROR.', 'File');
$destination = 'core/misc/druplicon.png';
$path = $file_system->getDestinationFilename($destination, FileSystemInterface::EXISTS_REPLACE);
- $this->assertEqual($path, $destination, 'Existing filepath destination remains the same with FILE_EXISTS_REPLACE.', 'File');
+ $this->assertEqual($path, $destination, 'Existing filepath destination remains the same with FileSystemInterface::EXISTS_REPLACE.', 'File');
$path = $file_system->getDestinationFilename($destination, FileSystemInterface::EXISTS_RENAME);
- $this->assertNotEqual($path, $destination, 'A new filepath destination is created when filepath destination already exists with FILE_EXISTS_RENAME.', 'File');
+ $this->assertNotEqual($path, $destination, 'A new filepath destination is created when filepath destination already exists with FileSystemInterface::EXISTS_RENAME.', 'File');
$path = $file_system->getDestinationFilename($destination, FileSystemInterface::EXISTS_ERROR);
- $this->assertEqual($path, FALSE, 'An error is returned when filepath destination already exists with FILE_EXISTS_ERROR.', 'File');
+ $this->assertEqual($path, FALSE, 'An error is returned when filepath destination already exists with FileSystemInterface::EXISTS_ERROR.', 'File');
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/File/FileCopyTest.php b/core/tests/Drupal/KernelTests/Core/File/FileCopyTest.php
index e0cb150a36..acce6ad98c 100644
--- a/core/tests/Drupal/KernelTests/Core/File/FileCopyTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/FileCopyTest.php
@@ -5,6 +5,7 @@
use Drupal\Core\File\Exception\FileExistsException;
use Drupal\Core\File\Exception\FileNotExistsException;
use Drupal\Core\File\FileSystem;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Site\Settings;
/**
@@ -23,7 +24,7 @@ public function testNormal() {
// Copying to a new name.
$desired_filepath = 'public://' . $this->randomMachineName();
- $new_filepath = \Drupal::service('file_system')->copy($uri, $desired_filepath, FILE_EXISTS_ERROR);
+ $new_filepath = \Drupal::service('file_system')->copy($uri, $desired_filepath, FileSystemInterface::EXISTS_ERROR);
$this->assertTrue($new_filepath, 'Copy was successful.');
$this->assertEqual($new_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($uri), 'Original file remains.');
@@ -33,7 +34,7 @@ public function testNormal() {
// Copying with rename.
$desired_filepath = 'public://' . $this->randomMachineName();
$this->assertTrue(file_put_contents($desired_filepath, ' '), 'Created a file so a rename will have to happen.');
- $newer_filepath = \Drupal::service('file_system')->copy($uri, $desired_filepath, FILE_EXISTS_RENAME);
+ $newer_filepath = \Drupal::service('file_system')->copy($uri, $desired_filepath, FileSystemInterface::EXISTS_RENAME);
$this->assertTrue($newer_filepath, 'Copy was successful.');
$this->assertNotEqual($newer_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($uri), 'Original file remains.');
@@ -66,7 +67,7 @@ public function testOverwriteSelf() {
// Copy the file onto itself with renaming works.
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
- $new_filepath = $file_system->copy($uri, $uri, FILE_EXISTS_RENAME);
+ $new_filepath = $file_system->copy($uri, $uri, FileSystemInterface::EXISTS_RENAME);
$this->assertTrue($new_filepath, 'Copying onto itself with renaming works.');
$this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.');
$this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.');
@@ -75,17 +76,17 @@ public function testOverwriteSelf() {
// Copy the file onto itself without renaming fails.
$this->expectException(FileExistsException::class);
- $new_filepath = $file_system->copy($uri, $uri, FILE_EXISTS_ERROR);
+ $new_filepath = $file_system->copy($uri, $uri, FileSystemInterface::EXISTS_ERROR);
$this->assertFalse($new_filepath, 'Copying onto itself without renaming fails.');
$this->assertTrue(file_exists($uri), 'File exists after copying onto itself.');
// Copy the file into same directory without renaming fails.
- $new_filepath = $file_system->copy($uri, drupal_dirname($uri), FILE_EXISTS_ERROR);
+ $new_filepath = $file_system->copy($uri, drupal_dirname($uri), FileSystemInterface::EXISTS_ERROR);
$this->assertFalse($new_filepath, 'Copying onto itself fails.');
$this->assertTrue(file_exists($uri), 'File exists after copying onto itself.');
// Copy the file into same directory with renaming works.
- $new_filepath = $file_system->copy($uri, drupal_dirname($uri), FILE_EXISTS_RENAME);
+ $new_filepath = $file_system->copy($uri, drupal_dirname($uri), FileSystemInterface::EXISTS_RENAME);
$this->assertTrue($new_filepath, 'Copying into same directory works.');
$this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.');
$this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.');
diff --git a/core/tests/Drupal/KernelTests/Core/File/FileMoveTest.php b/core/tests/Drupal/KernelTests/Core/File/FileMoveTest.php
index 9827d89817..6f23005894 100644
--- a/core/tests/Drupal/KernelTests/Core/File/FileMoveTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/FileMoveTest.php
@@ -4,6 +4,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\Exception\FileNotExistsException;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\File\FileSystem;
@@ -25,7 +26,7 @@ public function testNormal() {
$desired_filepath = 'public://' . $this->randomMachineName();
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
- $new_filepath = $file_system->move($uri, $desired_filepath, FILE_EXISTS_ERROR);
+ $new_filepath = $file_system->move($uri, $desired_filepath, FileSystemInterface::EXISTS_ERROR);
$this->assertTrue($new_filepath, 'Move was successful.');
$this->assertEqual($new_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($new_filepath), 'File exists at the new location.');
@@ -36,7 +37,7 @@ public function testNormal() {
$desired_filepath = 'public://' . $this->randomMachineName();
$this->assertTrue(file_exists($new_filepath), 'File exists before moving.');
$this->assertTrue(file_put_contents($desired_filepath, ' '), 'Created a file so a rename will have to happen.');
- $newer_filepath = $file_system->move($new_filepath, $desired_filepath, FILE_EXISTS_RENAME);
+ $newer_filepath = $file_system->move($new_filepath, $desired_filepath, FileSystemInterface::EXISTS_RENAME);
$this->assertTrue($newer_filepath, 'Move was successful.');
$this->assertNotEqual($newer_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($newer_filepath), 'File exists at the new location.');
@@ -68,12 +69,12 @@ public function testOverwriteSelf() {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$this->expectException(FileException::class);
- $new_filepath = $file_system->move($uri, $uri, FILE_EXISTS_REPLACE);
+ $new_filepath = $file_system->move($uri, $uri, FileSystemInterface::EXISTS_REPLACE);
$this->assertFalse($new_filepath, 'Moving onto itself without renaming fails.');
$this->assertTrue(file_exists($uri), 'File exists after moving onto itself.');
// Move the file onto itself with renaming will result in a new filename.
- $new_filepath = $file_system->move($uri, $uri, FILE_EXISTS_RENAME);
+ $new_filepath = $file_system->move($uri, $uri, FileSystemInterface::EXISTS_RENAME);
$this->assertTrue($new_filepath, 'Moving onto itself with renaming works.');
$this->assertFalse(file_exists($uri), 'Original file has been removed.');
$this->assertTrue(file_exists($new_filepath), 'File exists after moving onto itself.');
diff --git a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
index 119c580598..0496973a7d 100644
--- a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
@@ -2,6 +2,7 @@
namespace Drupal\KernelTests\Core\Image;
+use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Image\ImageInterface;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Site\Settings;
@@ -274,7 +275,7 @@ public function testManipulations() {
// Prepare a directory for test file results.
$directory = Settings::get('file_public_path') . '/imagetest';
- \Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
foreach ($files as $file) {
foreach ($operations as $op => $values) {
@@ -450,7 +451,7 @@ public function testResourceDestruction() {
public function testGifTransparentImages() {
// Prepare a directory for test file results.
$directory = Settings::get('file_public_path') . '/imagetest';
- \Drupal::service('file_system')->prepareDirectory($directory, FILE_CREATE_DIRECTORY);
+ \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
// Test loading an indexed GIF image with transparent color set.
// Color at top-right pixel should be fully transparent.