Skip to content

Commit

Permalink
Using new file mover and improving response message in case of some f…
Browse files Browse the repository at this point in the history
…ailures
  • Loading branch information
nWidart committed Oct 10, 2017
1 parent 09055ee commit cfde81a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Modules/Media/Http/Controllers/Api/MoveMediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Modules\Media\Http\Requests\MoveMediaRequest;
use Modules\Media\Repositories\FileRepository;
use Modules\Media\Repositories\FolderRepository;
use Modules\Media\Services\FileMover;
use Modules\Media\Services\FolderMover;

class MoveMediaController extends Controller
Expand All @@ -23,12 +24,22 @@ class MoveMediaController extends Controller
* @var FolderMover
*/
private $folderMover;
/**
* @var FileMover
*/
private $fileMover;

public function __construct(FileRepository $file, FolderRepository $folder, FolderMover $folderMover)
public function __construct(
FileRepository $file,
FolderRepository $folder,
FolderMover $folderMover,
FileMover $fileMover
)
{
$this->file = $file;
$this->folder = $folder;
$this->folderMover = $folderMover;
$this->fileMover = $fileMover;
}

public function __invoke(MoveMediaRequest $request)
Expand All @@ -43,7 +54,9 @@ public function __invoke(MoveMediaRequest $request)
$file = $this->file->find($file['id']);

if ($file->is_folder === false) {
$this->file->move($file, $destination);
if ($this->fileMover->move($file, $destination) === false) {
$failedMoves++;
}
}
if ($file->is_folder === true) {
if ($this->folderMover->move($file, $destination) === false) {
Expand Down

0 comments on commit cfde81a

Please sign in to comment.