Commit ad9e773f authored by Sam Mortenson's avatar Sam Mortenson

Fixed remaining deprecations.

parent 5b47fb0a
......@@ -91,7 +91,7 @@ class StaticDownloadController extends ControllerBase {
* Downloads a tarball of the static build.
*/
public function download() {
$path = file_directory_temp() . '/tome_static_export.tar.gz';
$path = $this->fileSystem->getTempDirectory() . '/tome_static_export.tar.gz';
$static_directory = $this->static->getStaticDirectory();
$this->fileSystem->delete($path);
......
......@@ -2,15 +2,15 @@
namespace Drupal\tome_sync\Commands;
use Drupal\Core\Config\StorageInterface;
use Drupal\tome_base\CommandBase;
use Drupal\tome_base\PathTrait;
use Drupal\tome_sync\ContentIndexerTrait;
use Drupal\tome_sync\FileSyncInterface;
use Drupal\tome_base\CommandBase;
use Drupal\tome_sync\TomeSyncHelper;
use Drupal\tome_sync\FileSyncInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\tome_sync\ContentIndexerTrait;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
/**
* Contains the tome:clean-files command.
......@@ -109,7 +109,7 @@ class CleanFilesCommand extends CommandBase {
foreach ($names as $name) {
$data = $this->contentStorage->read($name);
list(, $uuid) = TomeSyncHelper::getPartsFromContentName($name);
$files[$uuid] = file_uri_target($data['uri'][0]['value']);
$files[$uuid] = StreamWrapperManagerInterface::getTarget($data['uri'][0]['value']);
}
$callback = function ($value) use (&$files) {
if (is_string($value)) {
......
......@@ -3,7 +3,7 @@
namespace Drupal\tome_sync\Event;
use Drupal\Core\Entity\ContentEntityInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\Event;
/**
* Wraps a content event for listeners.
......
......@@ -5,7 +5,6 @@ namespace Drupal\tome_sync;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\Session\AccountSwitcherInterface;
use Drupal\file\FileInterface;
use Drupal\tome_base\PathTrait;
......
......@@ -9,6 +9,7 @@ use Drupal\Core\Config\StorageException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Component\FileSecurity\FileSecurity;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
/**
* Handles file import and exports by keeping a file export directory in sync.
......@@ -42,7 +43,7 @@ class FileSync implements FileSyncInterface {
public function importFiles() {
$file_directory = $this->getFileDirectory();
/** @var \Drupal\file\FileInterface $file */
foreach (file_scan_directory($file_directory, '/.*/') as $file) {
foreach ($this->fileSystem->scanDirectory($file_directory, '/.*/') as $file) {
$destination = 'public://' . ltrim(str_replace($file_directory, '', $file->uri), '/');
$directory = dirname($destination);
$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
......@@ -56,7 +57,7 @@ class FileSync implements FileSyncInterface {
public function deleteExportDirectory() {
$file_directory = $this->getFileDirectory();
if (file_exists($file_directory)) {
if (!file_unmanaged_delete_recursive($file_directory)) {
if (!$this->fileSystem->deleteRecursive($file_directory)) {
return FALSE;
}
}
......@@ -83,7 +84,7 @@ class FileSync implements FileSyncInterface {
public function deleteFileExport(FileInterface $file) {
$file_directory = $this->getFileDirectory();
if (strpos($file->getFileUri(), 'public://') === 0) {
$path = $this->joinPaths($file_directory, file_uri_target($file->getFileUri()));
$path = $this->joinPaths($file_directory, StreamWrapperManagerInterface::getTarget($file->getFileUri()));
if (file_exists($path)) {
$this->fileSystem->delete($path);
}
......
......@@ -2,8 +2,9 @@
namespace Drupal\Tests\tome_sync\Kernel;
use Drupal\Core\Site\Settings;
use Drupal\file\Entity\File;
use Drupal\Core\Site\Settings;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Tests\tome_base\Kernel\TestBase;
/**
......@@ -20,11 +21,19 @@ class FileSyncTest extends TestBase {
'tome_sync',
];
/**
* The file system.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->fileSystem = \Drupal::service('file_system');
$this->installSchema('tome_sync', ['tome_sync_content_hash']);
}
......@@ -33,7 +42,7 @@ class FileSyncTest extends TestBase {
*/
public function testImportFiles() {
$directory = Settings::get('tome_files_directory') . '/public/foo';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
touch(Settings::get('tome_files_directory') . '/public/foo/example.txt');
touch(Settings::get('tome_files_directory') . '/public/example.txt');
\Drupal::service('tome_sync.file_sync')->importFiles();
......@@ -46,7 +55,7 @@ class FileSyncTest extends TestBase {
*/
public function testDeleteExportDirectory() {
$directory = Settings::get('tome_files_directory') . '/public';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
touch($directory . '/example.txt');
\Drupal::service('tome_sync.file_sync')->deleteExportDirectory();
$this->assertFalse(file_exists($directory));
......@@ -57,7 +66,7 @@ class FileSyncTest extends TestBase {
*/
public function testDeleteFile() {
$directory = Settings::get('tome_files_directory') . '/public';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
touch($directory . '/example.txt');
\Drupal::service('tome_sync.file_sync')->deleteFile('example.txt');
$this->assertFalse(file_exists($directory . '/example.txt'));
......
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