Unverified Commit 2348afa4 authored by alexpott's avatar alexpott
Browse files

Issue #2940135 by andypost, Berdir, alexpott: Use file_system service to...

Issue #2940135 by andypost, Berdir, alexpott: Use file_system service to \Drupal\Core\Config\FileStorage
parent 8cd35dbe
......@@ -76,7 +76,7 @@ public static function getFileExtension() {
*/
protected function ensureStorage() {
$dir = $this->getCollectionDirectory();
$success = \Drupal::service('file_system')->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
$success = $this->getFileSystem()->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);
......@@ -156,7 +156,7 @@ public function write($name, array $data) {
throw new StorageException('Failed to write configuration file: ' . $this->getFilePath($name));
}
else {
\Drupal::service('file_system')->chmod($target);
$this->getFileSystem()->chmod($target);
}
$this->fileCache->set($target, $data);
......@@ -172,7 +172,7 @@ public function delete($name) {
return FALSE;
}
$this->fileCache->delete($this->getFilePath($name));
return drupal_unlink($this->getFilePath($name));
return $this->getFileSystem()->unlink($this->getFilePath($name));
}
/**
......@@ -248,7 +248,7 @@ public function deleteAll($prefix = '') {
if ($success && $this->collection != StorageInterface::DEFAULT_COLLECTION) {
// Remove empty directories.
if (!(new \FilesystemIterator($this->getCollectionDirectory()))->valid()) {
\Drupal::service('file_system')->rmdir($this->getCollectionDirectory());
$this->getFileSystem()->rmdir($this->getCollectionDirectory());
}
}
return $success;
......@@ -358,4 +358,14 @@ protected function getCollectionDirectory() {
return $dir;
}
/**
* Returns file system service.
*
* @return \Drupal\Core\File\FileSystemInterface
* The file system service.
*/
private function getFileSystem() {
return \Drupal::service('file_system');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment