diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php index e9ccccd..e7c43d1 100644 --- a/core/modules/color/tests/src/Functional/ColorTest.php +++ b/core/modules/color/tests/src/Functional/ColorTest.php @@ -141,7 +141,7 @@ function _testColor($theme, $test_values) { $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array(); $stylesheet_content = ''; foreach ($stylesheets as $uri) { - $stylesheet_content .= join("\n", file($this->container->get('file_system')->realpath($uri))); + $stylesheet_content .= join("\n", file(\Drupal::service('file_system')->realpath($uri))); } $this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')'); $config->set('css.preprocess', 0); diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php index 4c3bd83..4cc7f6b 100644 --- a/core/modules/comment/src/Tests/CommentPreviewTest.php +++ b/core/modules/comment/src/Tests/CommentPreviewTest.php @@ -55,7 +55,7 @@ function testCommentPreview() { // Add a user picture. $image = current($this->drupalGetTestFiles('image')); - $user_edit['files[user_picture_0]'] = $this->container->get('file_system')->realpath($image->uri); + $user_edit['files[user_picture_0]'] = \Drupal::service('file_system')->realpath($image->uri); $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $user_edit, t('Save')); // As the web user, fill in the comment form and preview the comment. diff --git a/core/modules/config/src/Tests/ConfigImportUploadTest.php b/core/modules/config/src/Tests/ConfigImportUploadTest.php index 3018cbd..c7479e5 100644 --- a/core/modules/config/src/Tests/ConfigImportUploadTest.php +++ b/core/modules/config/src/Tests/ConfigImportUploadTest.php @@ -42,7 +42,7 @@ function testImport() { // Attempt to upload a non-tar file. $text_file = current($this->drupalGetTestFiles('text')); - $edit = array('files[import_tarball]' => $this->container->get('file_system')->realpath($text_file->uri)); + $edit = array('files[import_tarball]' => \Drupal::service('file_system')->realpath($text_file->uri)); $this->drupalPostForm('admin/config/development/configuration/full/import', $edit, t('Upload')); $this->assertText(t('Could not extract the contents of the tar file')); diff --git a/core/modules/editor/src/Tests/EditorUploadImageScaleTest.php b/core/modules/editor/src/Tests/EditorUploadImageScaleTest.php index 767038e..100fb4f 100644 --- a/core/modules/editor/src/Tests/EditorUploadImageScaleTest.php +++ b/core/modules/editor/src/Tests/EditorUploadImageScaleTest.php @@ -188,7 +188,7 @@ protected function setMaxDimensions($width, $height) { */ protected function uploadImage($uri) { $edit = [ - 'files[fid]' => $this->container->get('file_system')->realpath($uri), + 'files[fid]' => \Drupal::service('file_system')->realpath($uri), ]; $this->drupalGet('editor/dialog/image/basic_html'); $this->drupalPostForm('editor/dialog/image/basic_html', $edit, t('Upload')); diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php index a10bd40..4b14aeb 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php @@ -115,7 +115,7 @@ public function testFileUpload() { $this->drupalLogin($user1); $test_file = current($this->drupalGetTestFiles('text')); - $edit['files[file_field_0]'] = $this->container->get('file_system')->realpath($test_file->uri); + $edit['files[file_field_0]'] = \Drupal::service('file_system')->realpath($test_file->uri); $this->drupalPostForm('node/add/' . $this->referencingType, $edit, 'Upload'); $this->assertResponse(200); $edit = array( diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php index ff9678d..9a6f3ac 100644 --- a/core/modules/file/src/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php @@ -96,7 +96,7 @@ function testNodeDisplay() { // Test that fields appear as expected after during the preview. // Add a second file. $name = 'files[' . $field_name . '_1][]'; - $edit[$name] = $this->container->get('file_system')->realpath($test_file->getFileUri()); + $edit[$name] = \Drupal::service('file_system')->realpath($test_file->getFileUri()); // Uncheck the display checkboxes and go to the preview. $edit[$field_name . '[0][display]'] = FALSE; @@ -165,7 +165,7 @@ function testDescToggle() { $title = $this->randomString(); $edit = array( 'title[0][value]' => $title, - 'files[field_' . $field_name . '_0]' => $this->container->get('file_system')->realpath($file->uri), + 'files[field_' . $field_name . '_0]' => \Drupal::service('file_system')->realpath($file->uri), ); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle($title); diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php index 004cbe2..1c2141a 100644 --- a/core/modules/file/src/Tests/FileFieldTestBase.php +++ b/core/modules/file/src/Tests/FileFieldTestBase.php @@ -248,7 +248,7 @@ function removeNodeFile($nid, $new_revision = TRUE) { */ function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { $edit = array( - 'files[' . $field_name . '_0]' => $this->container->get('file_system')->realpath($file->getFileUri()), + 'files[' . $field_name . '_0]' => \Drupal::service('file_system')->realpath($file->getFileUri()), 'revision' => (string) (int) $new_revision, ); diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php index 697eff4..63eb972 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -160,7 +160,7 @@ function testMultiValuedWidget() { $this->drupalGet("node/add/$type_name"); foreach (array($field_name2, $field_name) as $each_field_name) { for ($delta = 0; $delta < 3; $delta++) { - $edit = array('files[' . $each_field_name . '_' . $delta . '][]' => $this->container->get('file_system')->realpath($test_file->getFileUri())); + $edit = array('files[' . $each_field_name . '_' . $delta . '][]' => \Drupal::service('file_system')->realpath($test_file->getFileUri())); // If the Upload button doesn't exist, drupalPostForm() will automatically // fail with an assertion message. $this->drupalPostForm(NULL, $edit, t('Upload')); @@ -374,7 +374,7 @@ function testPrivateFileComment() { // Add a comment with a file. $text_file = $this->getTestFile('text'); $edit = array( - 'files[field_' . $name . '_' . 0 . ']' => $this->container->get('file_system')->realpath($text_file->getFileUri()), + 'files[field_' . $name . '_' . 0 . ']' => \Drupal::service('file_system')->realpath($text_file->getFileUri()), 'comment_body[0][value]' => $comment_body = $this->randomMachineName(), ); $this->drupalPostForm('node/' . $node->id(), $edit, t('Save')); @@ -429,7 +429,7 @@ function testWidgetValidation() { $name = 'files[' . $field_name . '_0]'; // Upload file with incorrect extension, check for validation error. - $edit[$name] = $this->container->get('file_system')->realpath($test_file_image->getFileUri()); + $edit[$name] = \Drupal::service('file_system')->realpath($test_file_image->getFileUri()); switch ($type) { case 'nojs': $this->drupalPostForm(NULL, $edit, t('Upload')); @@ -443,7 +443,7 @@ function testWidgetValidation() { $this->assertRaw($error_message, t('Validation error when file with wrong extension uploaded (JSMode=%type).', array('%type' => $type))); // Upload file with correct extension, check that error message is removed. - $edit[$name] = $this->container->get('file_system')->realpath($test_file_text->getFileUri()); + $edit[$name] = \Drupal::service('file_system')->realpath($test_file_text->getFileUri()); switch ($type) { case 'nojs': $this->drupalPostForm(NULL, $edit, t('Upload')); diff --git a/core/modules/file/src/Tests/FileListingTest.php b/core/modules/file/src/Tests/FileListingTest.php index 65d517f..2413187 100644 --- a/core/modules/file/src/Tests/FileListingTest.php +++ b/core/modules/file/src/Tests/FileListingTest.php @@ -91,7 +91,7 @@ function testFileListingPages() { $file = $this->getTestFile('image'); $edit = array( - 'files[file_0]' => $this->container->get('file_system')->realpath($file->getFileUri()), + 'files[file_0]' => \Drupal::service('file_system')->realpath($file->getFileUri()), ); $this->drupalPostForm(NULL, $edit, t('Save')); $node = Node::load($node->id()); diff --git a/core/modules/file/src/Tests/FileManagedFileElementTest.php b/core/modules/file/src/Tests/FileManagedFileElementTest.php index b320db0..1fe9cb2 100644 --- a/core/modules/file/src/Tests/FileManagedFileElementTest.php +++ b/core/modules/file/src/Tests/FileManagedFileElementTest.php @@ -36,7 +36,7 @@ function testManagedFile() { // was not saved. $last_fid_prior = $this->getLastFileId(); $edit = [ - $file_field_name => $this->container->get('file_system')->realpath($test_file->getFileUri()), + $file_field_name => \Drupal::service('file_system')->realpath($test_file->getFileUri()), 'form_token' => 'invalid token', ]; $this->drupalPostForm($path, $edit, t('Save')); @@ -46,7 +46,7 @@ function testManagedFile() { // Submit a new file, without using the Upload button. $last_fid_prior = $this->getLastFileId(); - $edit = array($file_field_name => $this->container->get('file_system')->realpath($test_file->getFileUri())); + $edit = array($file_field_name => \Drupal::service('file_system')->realpath($test_file->getFileUri())); $this->drupalPostForm($path, $edit, t('Save')); $last_fid = $this->getLastFileId(); $this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.'); @@ -61,7 +61,7 @@ function testManagedFile() { // Upload, then Submit. $last_fid_prior = $this->getLastFileId(); $this->drupalGet($path); - $edit = array($file_field_name => $this->container->get('file_system')->realpath($test_file->getFileUri())); + $edit = array($file_field_name => \Drupal::service('file_system')->realpath($test_file->getFileUri())); if ($ajax) { $this->drupalPostAjaxForm(NULL, $edit, $input_base_name . '_upload_button'); } @@ -92,7 +92,7 @@ function testManagedFile() { // Upload, then Remove, then Submit. $this->drupalGet($path); - $edit = array($file_field_name => $this->container->get('file_system')->realpath($test_file->getFileUri())); + $edit = array($file_field_name => \Drupal::service('file_system')->realpath($test_file->getFileUri())); if ($ajax) { $this->drupalPostAjaxForm(NULL, $edit, $input_base_name . '_upload_button'); } @@ -120,7 +120,7 @@ function testManagedFile() { // The multiple file upload has additional conditions that need checking. $path = 'file/test/1/1/1'; - $edit = array('files[nested_file][]' => $this->container->get('file_system')->realpath($test_file->getFileUri())); + $edit = array('files[nested_file][]' => \Drupal::service('file_system')->realpath($test_file->getFileUri())); $fid_list = array(); $this->drupalGet($path); @@ -158,7 +158,7 @@ public function testManagedFileRemoved() { $test_file = $this->getTestFile('text'); $file_field_name = 'files[nested_file][]'; - $edit = [$file_field_name => $this->container->get('file_system')->realpath($test_file->getFileUri())]; + $edit = [$file_field_name => \Drupal::service('file_system')->realpath($test_file->getFileUri())]; $this->drupalPostForm(NULL, $edit, t('Upload')); $fid = $this->getLastFileId(); @@ -179,7 +179,7 @@ public function testFileRemovedFromDisk() { $test_file = $this->getTestFile('text'); $file_field_name = 'files[nested_file][]'; - $edit = [$file_field_name => $this->container->get('file_system')->realpath($test_file->getFileUri())]; + $edit = [$file_field_name => \Drupal::service('file_system')->realpath($test_file->getFileUri())]; $this->drupalPostForm(NULL, $edit, t('Upload')); $this->drupalPostForm(NULL, array(), t('Save')); diff --git a/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php b/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php index cc5c415..6cb759f 100644 --- a/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php +++ b/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php @@ -86,7 +86,7 @@ public function testSyncedFiles() { // Edit the node to upload a file. $edit = array(); $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('text')[0]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[0]->uri); $this->drupalPostForm('node/' . $default_language_node->id() . '/edit', $edit, t('Save')); $first_fid = $this->getLastFileId(); @@ -97,7 +97,7 @@ public function testSyncedFiles() { $edit = array(); $edit['title[0][value]'] = 'Bill Murray'; $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('text')[1]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[1]->uri); $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); // This inspects the HTML after the post of the translation, the file // should be displayed on the original node. @@ -123,7 +123,7 @@ public function testSyncedFiles() { $edit = array(); $edit['title[0][value]'] = 'Scarlett Johansson'; $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('text')[2]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[2]->uri); $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); $third_fid = $this->getLastFileId(); @@ -151,7 +151,7 @@ public function testSyncedFiles() { $edit = array(); $edit['title[0][value]'] = 'David Bowie'; $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('text')[3]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[3]->uri); $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); $replaced_second_fid = $this->getLastFileId(); diff --git a/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php b/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php index 2ab92fa..f04660d 100644 --- a/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php +++ b/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php @@ -80,7 +80,7 @@ public function testPrivateLanguageFile() { // Edit the node to upload a file. $edit = array(); $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('text')[0]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[0]->uri); $this->drupalPostForm('node/' . $default_language_node->id() . '/edit', $edit, t('Save')); $last_fid_prior = $this->getLastFileId(); @@ -105,7 +105,7 @@ public function testPrivateLanguageFile() { $edit = array(); $edit['title[0][value]'] = $this->randomMachineName(); $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('text')[1]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[1]->uri); $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); $last_fid = $this->getLastFileId(); diff --git a/core/modules/file/src/Tests/SaveUploadTest.php b/core/modules/file/src/Tests/SaveUploadTest.php index f82b336..60a6393 100644 --- a/core/modules/file/src/Tests/SaveUploadTest.php +++ b/core/modules/file/src/Tests/SaveUploadTest.php @@ -60,7 +60,7 @@ protected function setUp() { // Upload with replace to guarantee there's something there. $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()), + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -88,7 +88,7 @@ function testNormal() { // Upload a second file. $image2 = current($this->drupalGetTestFiles('image')); - $edit = array('files[file_test_upload]' => $this->container->get('file_system')->realpath($image2->uri)); + $edit = array('files[file_test_upload]' => \Drupal::service('file_system')->realpath($image2->uri)); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); $this->assertRaw(t('You WIN!')); @@ -109,7 +109,7 @@ function testNormal() { // Upload a third file to a subdirectory. $image3 = current($this->drupalGetTestFiles('image')); - $image3_realpath = $this->container->get('file_system')->realpath($image3->uri); + $image3_realpath = \Drupal::service('file_system')->realpath($image3->uri); $dir = $this->randomMachineName(); $edit = array( 'files[file_test_upload]' => $image3_realpath, @@ -132,7 +132,7 @@ function testHandleExtension() { $extensions = 'foo'; $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()), + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), 'extensions' => $extensions, ); @@ -152,7 +152,7 @@ function testHandleExtension() { // Now tell file_save_upload() to allow the extension of our test image. $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()), + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), 'extensions' => $extensions, ); @@ -170,7 +170,7 @@ function testHandleExtension() { // Now tell file_save_upload() to allow any extension. $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()), + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), 'allow_all_extensions' => TRUE, ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); @@ -191,7 +191,7 @@ function testHandleDangerousFile() { // safety. Also check to make sure its MIME type was changed. $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->phpfile->uri), + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->phpfile->uri), 'is_image_file' => FALSE, 'extensions' => 'php', ); @@ -238,7 +238,7 @@ function testHandleFileMunge() { $extensions = $this->imageExtension; $edit = array( - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()), + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), 'extensions' => $extensions, ); @@ -260,7 +260,7 @@ function testHandleFileMunge() { file_test_reset(); $edit = array( - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()), + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), 'allow_all_extensions' => TRUE, ); @@ -280,7 +280,7 @@ function testHandleFileMunge() { function testExistingRename() { $edit = array( 'file_test_replace' => FILE_EXISTS_RENAME, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()) + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()) ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -296,7 +296,7 @@ function testExistingRename() { function testExistingReplace() { $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()) + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()) ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -312,7 +312,7 @@ function testExistingReplace() { function testExistingError() { $edit = array( 'file_test_replace' => FILE_EXISTS_ERROR, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()) + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()) ); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -341,7 +341,7 @@ function testDrupalMovingUploadedFileError() { $edit = array( 'file_subdir' => $test_directory, - 'files[file_test_upload]' => $this->container->get('file_system')->realpath($this->image->getFileUri()) + 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()) ); \Drupal::state()->set('file_test.disable_error_collection', TRUE); diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php index fad0937..dfa0dc5 100644 --- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php @@ -302,7 +302,7 @@ public function testDefaultImages() { ); $non_image = $this->drupalGetTestFiles('text'); - $this->drupalPostForm(NULL, array('files[settings_default_image_uuid]' => $this->container->get('file_system')->realpath($non_image[0]->uri)), t("Upload")); + $this->drupalPostForm(NULL, array('files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($non_image[0]->uri)), t("Upload")); $this->assertText('The specified file text-0.txt could not be uploaded.'); $this->assertText('Only files with the following extensions are allowed: png gif jpg jpeg.'); diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php index 57c987f..6c54f34 100644 --- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php @@ -312,7 +312,7 @@ function testImageFieldSettings() { // @see FileWidget::formMultipleElements(). $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings')); $edit = array( - 'files[' . $field_name . '_1][]' => $this->container->get('file_system')->realpath($test_image->uri), + 'files[' . $field_name . '_1][]' => \Drupal::service('file_system')->realpath($test_image->uri), ); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); // Add the required alt text. @@ -322,7 +322,7 @@ function testImageFieldSettings() { // Assert ImageWidget::process() calls FieldWidget::process(). $this->drupalGet('node/' . $node->id() . '/edit'); $edit = array( - 'files[' . $field_name . '_2][]' => $this->container->get('file_system')->realpath($test_image->uri), + 'files[' . $field_name . '_2][]' => \Drupal::service('file_system')->realpath($test_image->uri), ); $this->drupalPostAjaxForm(NULL, $edit, $field_name . '_2_upload_button'); $this->assertNoRaw(''); @@ -357,7 +357,7 @@ function testImageFieldDefaultImage() { $title = $this->randomString(1024); $edit = array( // Get the path of the 'image-test.png' file. - 'files[settings_default_image_uuid]' => $this->container->get('file_system')->realpath($images[0]->uri), + 'files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($images[0]->uri), 'settings[default_image][alt]' => $alt, 'settings[default_image][title]' => $title, ); @@ -426,7 +426,7 @@ function testImageFieldDefaultImage() { // Add a default image to the new field. $edit = array( // Get the path of the 'image-test.gif' file. - 'files[settings_default_image_uuid]' => $this->container->get('file_system')->realpath($images[2]->uri), + 'files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($images[2]->uri), 'settings[default_image][alt]' => $alt, 'settings[default_image][title]' => $title, ); diff --git a/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php index a4d8eb0..3add105 100644 --- a/core/modules/image/src/Tests/ImageFieldTestBase.php +++ b/core/modules/image/src/Tests/ImageFieldTestBase.php @@ -66,7 +66,7 @@ function previewNodeImage($image, $field_name, $type) { $edit = array( 'title[0][value]' => $this->randomMachineName(), ); - $edit['files[' . $field_name . '_0]'] = $this->container->get('file_system')->realpath($image->uri); + $edit['files[' . $field_name . '_0]'] = \Drupal::service('file_system')->realpath($image->uri); $this->drupalPostForm('node/add/' . $type, $edit, t('Preview')); } @@ -86,7 +86,7 @@ function uploadNodeImage($image, $field_name, $type, $alt = '') { $edit = array( 'title[0][value]' => $this->randomMachineName(), ); - $edit['files[' . $field_name . '_0]'] = $this->container->get('file_system')->realpath($image->uri); + $edit['files[' . $field_name . '_0]'] = \Drupal::service('file_system')->realpath($image->uri); $this->drupalPostForm('node/add/' . $type, $edit, t('Save and publish')); if ($alt) { // Add alt text. diff --git a/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php b/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php index 93df909..6934c2b 100644 --- a/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php +++ b/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php @@ -92,7 +92,7 @@ public function testSyncedImages() { // Edit the node to upload a file. $edit = array(); $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('image')[0]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('image')[0]->uri); $this->drupalPostForm('node/' . $default_language_node->id() . '/edit', $edit, t('Save')); $edit = [$this->fieldName . '[0][alt]' => 'Lost in translation image', $this->fieldName . '[0][title]' => 'Lost in translation image title']; $this->drupalPostForm(NULL, $edit, t('Save')); @@ -105,7 +105,7 @@ public function testSyncedImages() { $edit = array(); $edit['title[0][value]'] = 'Scarlett Johansson'; $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('image')[1]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('image')[1]->uri); $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); $edit = [$this->fieldName . '[0][alt]' => 'Scarlett Johansson image', $this->fieldName . '[0][title]' => 'Scarlett Johansson image title']; $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); @@ -137,7 +137,7 @@ public function testSyncedImages() { $edit = array(); $edit['title[0][value]'] = 'Akiko Takeshita'; $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('image')[2]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('image')[2]->uri); $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); $edit = [$this->fieldName . '[0][alt]' => 'Akiko Takeshita image', $this->fieldName . '[0][title]' => 'Akiko Takeshita image title']; $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); @@ -172,7 +172,7 @@ public function testSyncedImages() { $edit = array(); $edit['title[0][value]'] = 'Giovanni Ribisi'; $name = 'files[' . $this->fieldName . '_0]'; - $edit[$name] = $this->container->get('file_system')->realpath($this->drupalGetTestFiles('image')[3]->uri); + $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('image')[3]->uri); $this->drupalPostForm(NULL, $edit, t('Save (this translation)')); $name = $this->fieldName . '[0][alt]'; diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php index 045a6e1..fc33008 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php @@ -138,7 +138,7 @@ protected function makePoFile($path, $filename, $timestamp = NULL, array $transl 'status' => FILE_STATUS_PERMANENT, ]); file_put_contents($file->getFileUri(), $po_header . $text); - touch($this->container->get('file_system')->realpath($file->getFileUri()), $timestamp); + touch(\Drupal::service('file_system')->realpath($file->getFileUri()), $timestamp); $file->save(); } diff --git a/core/modules/locale/src/Tests/LocaleUpdateCronTest.php b/core/modules/locale/src/Tests/LocaleUpdateCronTest.php index ae10d0f..d3ff635 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateCronTest.php +++ b/core/modules/locale/src/Tests/LocaleUpdateCronTest.php @@ -43,7 +43,7 @@ public function testUpdateCron() { // Prepare for test: Simulate new translations being available. // Change the last updated timestamp of a translation file. $contrib_module_two_uri = 'public://local/contrib_module_two-8.x-2.0-beta4.de._po'; - touch($this->container->get('file_system')->realpath($contrib_module_two_uri), REQUEST_TIME); + touch(\Drupal::service('file_system')->realpath($contrib_module_two_uri), REQUEST_TIME); // Prepare for test: Simulate that the file has not been checked for a long // time. Set the last_check timestamp to zero. diff --git a/core/modules/node/src/Tests/PagePreviewTest.php b/core/modules/node/src/Tests/PagePreviewTest.php index d13d11c..916289c 100644 --- a/core/modules/node/src/Tests/PagePreviewTest.php +++ b/core/modules/node/src/Tests/PagePreviewTest.php @@ -142,7 +142,7 @@ function testPagePreview() { // Upload an image. $test_image = current($this->drupalGetTestFiles('image', 39325)); - $edit['files[field_image_0][]'] = $this->container->get('file_system')->realpath($test_image->uri); + $edit['files[field_image_0][]'] = \Drupal::service('file_system')->realpath($test_image->uri); $this->drupalPostForm('node/add/page', $edit, t('Upload')); // Add an alt tag and preview the node. diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 61a73b6..12eeef1 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -12,7 +12,6 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfigFormBase; -use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Theme\ThemeManagerInterface; /** @@ -35,12 +34,6 @@ class ThemeSettingsForm extends ConfigFormBase { protected $themeHandler; /** - * File System instance. - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - - /** * The MIME type guesser. * * @var \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface @@ -72,17 +65,14 @@ class ThemeSettingsForm extends ConfigFormBase { * The theme handler. * @param \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $mime_type_guesser * The MIME type guesser instance to use. - * @param \Drupal\Core\File\FileSystemInterface $file_system - * The FileSytem instance to use. */ - public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, MimeTypeGuesserInterface $mime_type_guesser, ThemeManagerInterface $theme_manager, FileSystemInterface $file_system) { + public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, MimeTypeGuesserInterface $mime_type_guesser, ThemeManagerInterface $theme_manager) { parent::__construct($config_factory); $this->moduleHandler = $module_handler; $this->themeHandler = $theme_handler; $this->mimeTypeGuesser = $mime_type_guesser; $this->themeManager = $theme_manager; - $this->fileSystem = $file_system; } /** @@ -94,8 +84,7 @@ public static function create(ContainerInterface $container) { $container->get('module_handler'), $container->get('theme_handler'), $container->get('file.mime_type.guesser'), - $container->get('theme.manager'), - $container->get('file_system') + $container->get('theme.manager') ); } @@ -491,7 +480,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { */ protected function validatePath($path) { // Absolute local file paths are invalid. - if ($this->fileSystem->realpath($path) == $path) { + if (\Drupal::service('file_system')->realpath($path) == $path) { return FALSE; } // A path relative to the Drupal root or a fully qualified URI is valid. diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index bf84019..64e2a45 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -5,7 +5,6 @@ use Drupal\Component\Utility\Color; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\ImageToolkit\ImageToolkitBase; use Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface; @@ -61,13 +60,6 @@ class GDToolkit extends ImageToolkitBase { protected $streamWrapperManager; /** - * File System instance. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - - /** * Constructs a GDToolkit object. * * @param array $configuration @@ -84,13 +76,10 @@ class GDToolkit extends ImageToolkitBase { * The config factory. * @param \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager * The StreamWrapper manager. - * @param \Drupal\Core\File\FileSystemInterface $file_system - * The FileSytem instance to use. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger, ConfigFactoryInterface $config_factory, StreamWrapperManagerInterface $stream_wrapper_manager, FileSystemInterface $file_system) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger, ConfigFactoryInterface $config_factory, StreamWrapperManagerInterface $stream_wrapper_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $operation_manager, $logger, $config_factory); $this->streamWrapperManager = $stream_wrapper_manager; - $this->fileSystem = $file_system; } /** @@ -115,8 +104,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('image.toolkit.operation.manager'), $container->get('logger.channel.image'), $container->get('config.factory'), - $container->get('stream_wrapper_manager'), - $container->get('file_system') + $container->get('stream_wrapper_manager') ); } @@ -236,7 +224,7 @@ public function save($destination) { $destination = drupal_tempnam('temporary://', 'gd_'); } // Convert stream wrapper URI to normal path. - $destination = $this->fileSystem->realpath($destination); + $destination = \Drupal::service('file_system')->realpath($destination); } $function = 'image' . image_type_to_extension($this->getType(), FALSE); diff --git a/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php b/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php index 8c6fe08..b1c1c84 100644 --- a/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php +++ b/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php @@ -38,7 +38,7 @@ function testFormStateValuesCleanAdvanced() { $this->assertTrue(is_file($this->image->uri), "The image file we're going to upload exists."); // "Browse" for the desired file. - $edit = array('files[image]' => $this->container->get('file_system')->realpath($this->image->uri)); + $edit = array('files[image]' => \Drupal::service('file_system')->realpath($this->image->uri)); // Post the form. $this->drupalPostForm('form_test/form-state-values-clean-advanced', $edit, t('Submit')); diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index 2d65560..7f902a1 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -152,7 +152,7 @@ function testThemeSettings() { // Semi-absolute path to arbitrary non-existing file. '/core/misc/whatever.png', // Absolute paths to any local file (even if it exists). - $this->container->get('file_system')->realpath($file->uri), + \Drupal::service('file_system')->realpath($file->uri), ); $this->drupalGet('admin/appearance/settings'); foreach ($unsupported_paths as $path) { @@ -168,7 +168,7 @@ function testThemeSettings() { $edit = array( 'default_logo' => FALSE, 'logo_path' => '', - 'files[logo_upload]' => $this->container->get('file_system')->realpath($file->uri), + 'files[logo_upload]' => \Drupal::service('file_system')->realpath($file->uri), ); $this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration')); diff --git a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php index 409980e..23d363c 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php @@ -74,7 +74,7 @@ public function testTaxonomyImageAccess() { $files = $this->drupalGetTestFiles('image'); $image = array_pop($files); $edit['name[0][value]'] = $this->randomMachineName(); - $edit['files[field_test_0]'] = $this->container->get('file_system')->realpath($image->uri); + $edit['files[field_test_0]'] = \Drupal::service('file_system')->realpath($image->uri); $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save')); $this->drupalPostForm(NULL, ['field_test[0][alt]' => $this->randomMachineName()], t('Save')); $terms = entity_load_multiple_by_properties('taxonomy_term', array('name' => $edit['name[0][value]'])); diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php index 55a5f99..6029be2 100644 --- a/core/modules/text/src/Tests/TextFieldTest.php +++ b/core/modules/text/src/Tests/TextFieldTest.php @@ -113,7 +113,7 @@ function testRequiredLongTextWithFileUpload() { ->save(); $test_file = current($this->drupalGetTestFiles('text')); - $edit['files[file_field_0]'] = $this->container->get('file_system')->realpath($test_file->uri); + $edit['files[file_field_0]'] = \Drupal::service('file_system')->realpath($test_file->uri); $this->drupalPostForm('entity_test/add', $edit, 'Upload'); $this->assertResponse(200); $edit = array( diff --git a/core/modules/update/src/Form/UpdateReady.php b/core/modules/update/src/Form/UpdateReady.php index 93de7ad..d298b60 100644 --- a/core/modules/update/src/Form/UpdateReady.php +++ b/core/modules/update/src/Form/UpdateReady.php @@ -3,7 +3,6 @@ namespace Drupal\update\Form; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\File\FileSystemInterface; use Drupal\Core\FileTransfer\Local; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; @@ -46,13 +45,6 @@ class UpdateReady extends FormBase { protected $sitePath; /** - * File System instance. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - - /** * Constructs a new UpdateReady object. * * @param string $root @@ -63,15 +55,12 @@ class UpdateReady extends FormBase { * The state key value store. * @param string $site_path * The site path. - * @param \Drupal\Core\File\FileSystemInterface $file_system - * The FileSytem instance to use. */ - public function __construct($root, ModuleHandlerInterface $module_handler, StateInterface $state, $site_path, FileSystemInterface $file_system) { + public function __construct($root, ModuleHandlerInterface $module_handler, StateInterface $state, $site_path) { $this->root = $root; $this->moduleHandler = $module_handler; $this->state = $state; $this->sitePath = $site_path; - $this->fileSystem = $file_system; } /** @@ -89,8 +78,7 @@ public static function create(ContainerInterface $container) { $container->get('update.root'), $container->get('module_handler'), $container->get('state'), - $container->get('site.path'), - $container->get('file_system') + $container->get('site.path') ); } @@ -148,7 +136,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($projects as $project => $url) { $project_location = $directory . '/' . $project; $updater = Updater::factory($project_location, $this->root); - $project_real_location = $this->fileSystem->realpath($project_location); + $project_real_location = \Drupal::service('file_system')->realpath($project_location); $updates[] = array( 'project' => $project, 'updater_name' => get_class($updater), diff --git a/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php b/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php index d209fd1..3adbf9e 100644 --- a/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php +++ b/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php @@ -38,7 +38,7 @@ function testUpdateDeleteFileIfStale() { ->set('temporary_maximum_age', -100000) ->save(); - $file_path = $this->container->get('file_system')->realpath($file_name); + $file_path = \Drupal::service('file_system')->realpath($file_name); update_delete_file_if_stale($file_path); $this->assertFalse(is_file($file_path)); diff --git a/core/modules/user/src/Tests/UserPasswordResetTest.php b/core/modules/user/src/Tests/UserPasswordResetTest.php index fcfb3a6..520f9bb 100644 --- a/core/modules/user/src/Tests/UserPasswordResetTest.php +++ b/core/modules/user/src/Tests/UserPasswordResetTest.php @@ -118,7 +118,7 @@ function testUserPasswordReset() { // invalidate the reset token. $image = current($this->drupalGetTestFiles('image')); $edit = array( - 'files[user_picture_0]' => $this->container->get('file_system')->realpath($image->uri), + 'files[user_picture_0]' => \Drupal::service('file_system')->realpath($image->uri), ); $this->drupalPostAjaxForm(NULL, $edit, 'user_picture_0_upload_button'); diff --git a/core/modules/user/src/Tests/UserPictureTest.php b/core/modules/user/src/Tests/UserPictureTest.php index d405b21..67edde0 100644 --- a/core/modules/user/src/Tests/UserPictureTest.php +++ b/core/modules/user/src/Tests/UserPictureTest.php @@ -130,7 +130,7 @@ function testPictureOnNodeComment() { * Edits the user picture for the test user. */ function saveUserPicture($image) { - $edit = array('files[user_picture_0]' => $this->container->get('file_system')->realpath($image->uri)); + $edit = array('files[user_picture_0]' => \Drupal::service('file_system')->realpath($image->uri)); $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Save')); // Load actual user data from database. diff --git a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php index 4c3aa47..4d3305c 100644 --- a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php @@ -45,7 +45,7 @@ function testFileCheckLocalDirectoryHandling() { $this->assertDirectoryPermissions($directory, $old_mode); // Check creating a directory using an absolute path. - $absolute_path = $this->container->get('file_system')->realpath($directory) . DIRECTORY_SEPARATOR . $this->randomMachineName() . DIRECTORY_SEPARATOR . $this->randomMachineName(); + $absolute_path = \Drupal::service('file_system')->realpath($directory) . DIRECTORY_SEPARATOR . $this->randomMachineName() . DIRECTORY_SEPARATOR . $this->randomMachineName(); $this->assertTrue(drupal_mkdir($absolute_path, 0775, TRUE), 'No error reported when creating new absolute directories.', 'File'); $this->assertDirectoryPermissions($absolute_path, 0775); }