Using new file mover and improving response message in case of some failures

parent 09055ee1
...@@ -7,6 +7,7 @@ use Modules\Media\Entities\File; ...@@ -7,6 +7,7 @@ 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\FolderMover; use Modules\Media\Services\FolderMover;
class MoveMediaController extends Controller class MoveMediaController extends Controller
...@@ -23,12 +24,22 @@ class MoveMediaController extends Controller ...@@ -23,12 +24,22 @@ class MoveMediaController extends Controller
* @var FolderMover * @var FolderMover
*/ */
private $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->file = $file;
$this->folder = $folder; $this->folder = $folder;
$this->folderMover = $folderMover; $this->folderMover = $folderMover;
$this->fileMover = $fileMover;
} }
public function __invoke(MoveMediaRequest $request) public function __invoke(MoveMediaRequest $request)
...@@ -43,7 +54,9 @@ class MoveMediaController extends Controller ...@@ -43,7 +54,9 @@ class MoveMediaController extends Controller
$file = $this->file->find($file['id']); $file = $this->file->find($file['id']);
if ($file->is_folder === false) { if ($file->is_folder === false) {
$this->file->move($file, $destination); if ($this->fileMover->move($file, $destination) === false) {
$failedMoves++;
}
} }
if ($file->is_folder === true) { if ($file->is_folder === true) {
if ($this->folderMover->move($file, $destination) === false) { if ($this->folderMover->move($file, $destination) === false) {
......
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