diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index 67eef9c02d..e64e9a1dd0 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -33,6 +33,13 @@ class FileStorage implements StorageInterface { */ protected $fileCache; + /** + * The file system. + * + * @var \Drupal\Core\File\FileSystemInterface + */ + protected $fileSystem; + /** * Constructs a new FileStorage. * @@ -45,6 +52,8 @@ class FileStorage implements StorageInterface { public function __construct($directory, $collection = StorageInterface::DEFAULT_COLLECTION) { $this->directory = $directory; $this->collection = $collection; + // @todo Inject the service in https://www.drupal.org/project/drupal/issues/3023222. + $this->fileSystem = \Drupal::service('file_system'); // Use a NULL File Cache backend by default. This will ensure only the // internal static caching of FileCache is used and thus avoids blowing up @@ -77,7 +86,7 @@ public static function getFileExtension() { */ protected function ensureStorage() { $dir = $this->getCollectionDirectory(); - $success = $this->getFileSystem()->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); + $success = $this->fileSystem->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); // Only create .htaccess file in root directory. if ($dir == $this->directory) { $success = $success && file_save_htaccess($this->directory, TRUE, TRUE); @@ -260,7 +269,8 @@ public function deleteAll($prefix = '') { */ public function createCollection($collection) { return new static( - $collection, $this->directory + $this->directory, + $collection ); } @@ -358,14 +368,4 @@ protected function getCollectionDirectory() { return $dir; } - /** - * Wrapper method for the file system. - * - * @return \Drupal\Core\File\FileSystemInterface - * The file system. - */ - protected function getFileSystem() { - return \Drupal::service('file_system'); - } - }