Moving the file and folder movers inside their own namespace

parent 6bc55223
...@@ -7,8 +7,8 @@ use Modules\Media\Entities\File; ...@@ -7,8 +7,8 @@ use Modules\Media\Entities\File;
use Modules\Media\Http\Requests\MoveMediaRequest; use Modules\Media\Http\Requests\MoveMediaRequest;
use Modules\Media\Repositories\FileRepository; use Modules\Media\Repositories\FileRepository;
use Modules\Media\Repositories\FolderRepository; use Modules\Media\Repositories\FolderRepository;
use Modules\Media\Services\FileMover; use Modules\Media\Services\Movers\FileMover;
use Modules\Media\Services\FolderMover; use Modules\Media\Services\Movers\FolderMover;
class MoveMediaController extends Controller class MoveMediaController extends Controller
{ {
...@@ -49,7 +49,7 @@ class MoveMediaController extends Controller ...@@ -49,7 +49,7 @@ class MoveMediaController extends Controller
$failedMoves = 0; $failedMoves = 0;
foreach ($request->get('files') as $file) { foreach ($request->get('files') as $file) {
$file = $this->file->find($file['id']); $file = $this->file->find($file['id']);
// $this->>mover->move($file, $destination)
if ($file->is_folder === false) { if ($file->is_folder === false) {
if ($this->fileMover->move($file, $destination) === false) { if ($this->fileMover->move($file, $destination) === false) {
$failedMoves++; $failedMoves++;
......
<?php <?php
namespace Modules\Media\Services; namespace Modules\Media\Services\Movers;
use Illuminate\Contracts\Filesystem\Factory; use Illuminate\Contracts\Filesystem\Factory;
use League\Flysystem\FileExistsException; use League\Flysystem\FileExistsException;
...@@ -9,9 +9,8 @@ use Modules\Media\Image\Thumbnail; ...@@ -9,9 +9,8 @@ use Modules\Media\Image\Thumbnail;
use Modules\Media\Image\ThumbnailManager; use Modules\Media\Image\ThumbnailManager;
use Modules\Media\Repositories\FileRepository; use Modules\Media\Repositories\FileRepository;
use Modules\Media\Repositories\FolderRepository; use Modules\Media\Repositories\FolderRepository;
use Modules\Media\ValueObjects\MediaPath;
class FileMover implements Mover final class FileMover implements MoverInterface
{ {
/** /**
* All the different images types where thumbnails should be created * All the different images types where thumbnails should be created
......
<?php <?php
namespace Modules\Media\Services; namespace Modules\Media\Services\Movers;
use Illuminate\Contracts\Filesystem\Factory; use Illuminate\Contracts\Filesystem\Factory;
use League\Flysystem\FileExistsException; use League\Flysystem\FileExistsException;
...@@ -8,7 +8,7 @@ use Modules\Media\Entities\File; ...@@ -8,7 +8,7 @@ use Modules\Media\Entities\File;
use Modules\Media\Repositories\FileRepository; use Modules\Media\Repositories\FileRepository;
use Modules\Media\Repositories\FolderRepository; use Modules\Media\Repositories\FolderRepository;
final class FolderMover implements Mover final class FolderMover implements MoverInterface
{ {
/** /**
* @var Factory * @var Factory
......
<?php <?php
namespace Modules\Media\Services; namespace Modules\Media\Services\Movers;
use Modules\Media\Entities\File; use Modules\Media\Entities\File;
interface Mover interface MoverInterface
{ {
public function move(File $file, File $destination) : bool; public function move(File $file, File $destination) : bool;
} }
...@@ -5,7 +5,7 @@ namespace Modules\Media\Tests; ...@@ -5,7 +5,7 @@ namespace Modules\Media\Tests;
use Modules\Media\Entities\File; use Modules\Media\Entities\File;
use Modules\Media\Repositories\FileRepository; use Modules\Media\Repositories\FileRepository;
use Modules\Media\Repositories\FolderRepository; use Modules\Media\Repositories\FolderRepository;
use Modules\Media\Services\FileMover; use Modules\Media\Services\Movers\FileMover;
use Modules\Media\Services\FileService; use Modules\Media\Services\FileService;
final class FileMoverTest extends MediaTestCase final class FileMoverTest extends MediaTestCase
......
...@@ -5,7 +5,7 @@ namespace Modules\Media\Tests; ...@@ -5,7 +5,7 @@ namespace Modules\Media\Tests;
use Modules\Media\Entities\File; use Modules\Media\Entities\File;
use Modules\Media\Repositories\FolderRepository; use Modules\Media\Repositories\FolderRepository;
use Modules\Media\Services\FileService; use Modules\Media\Services\FileService;
use Modules\Media\Services\FolderMover; use Modules\Media\Services\Movers\FolderMover;
final class FolderMoverTest extends MediaTestCase final class FolderMoverTest extends MediaTestCase
{ {
......
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