mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
controller refactoring part 24
This commit is contained in:
@@ -14,7 +14,8 @@ class GetFileController extends Controller
|
||||
public function __construct(
|
||||
private RecordDownloadAction $recordDownload,
|
||||
private DownloadFileAction $downloadFile,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Files\Actions\DownloadFileAction;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
use Domain\Sharing\Actions\ProtectShareRecordAction;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Domain\Sharing\Actions\VerifyAccessToItemWithinAction;
|
||||
|
||||
/**
|
||||
* Get file public
|
||||
@@ -16,6 +18,8 @@ class VisitorGetFileController extends Controller
|
||||
public function __construct(
|
||||
private DownloadFileAction $downloadFile,
|
||||
private RecordDownloadAction $recordDownload,
|
||||
private ProtectShareRecordAction $protectShareRecord,
|
||||
private VerifyAccessToItemWithinAction $verifyAccessToItemWithin,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -24,15 +28,15 @@ class VisitorGetFileController extends Controller
|
||||
Share $shared,
|
||||
): BinaryFileResponse {
|
||||
// Check ability to access protected share files
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
($this->protectShareRecord)($shared);
|
||||
|
||||
// Get file record
|
||||
$file = UserFile::where('user_id', $shared->user_id)
|
||||
$file = File::where('user_id', $shared->user_id)
|
||||
->where('basename', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check file access
|
||||
$this->helper->check_guest_access_to_shared_items($shared, $file);
|
||||
($this->verifyAccessToItemWithin)($shared, $file);
|
||||
|
||||
// Store user download size
|
||||
($this->recordDownload)(
|
||||
@@ -40,6 +44,7 @@ class VisitorGetFileController extends Controller
|
||||
user_id: $shared->user_id,
|
||||
);
|
||||
|
||||
// Finally download file
|
||||
return ($this->downloadFile)($file, $shared->user_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
use Domain\Files\Actions\DownloadThumbnailAction;
|
||||
use Domain\Sharing\Actions\ProtectShareRecordAction;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Domain\Sharing\Actions\VerifyAccessToItemWithinAction;
|
||||
|
||||
/**
|
||||
* Get public image thumbnail
|
||||
@@ -16,6 +18,8 @@ class VisitorGetThumbnailController extends Controller
|
||||
public function __construct(
|
||||
private RecordDownloadAction $recordDownload,
|
||||
private DownloadThumbnailAction $downloadThumbnail,
|
||||
private ProtectShareRecordAction $protectShareRecord,
|
||||
private VerifyAccessToItemWithinAction $verifyAccessToItemWithin,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -24,7 +28,7 @@ class VisitorGetThumbnailController extends Controller
|
||||
Share $shared,
|
||||
): StreamedResponse {
|
||||
// Check ability to access protected share files
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
($this->protectShareRecord)($shared);
|
||||
|
||||
// Get file record
|
||||
$file = UserFile::where('user_id', $shared->user_id)
|
||||
@@ -32,7 +36,7 @@ class VisitorGetThumbnailController extends Controller
|
||||
->firstOrFail();
|
||||
|
||||
// Check file access
|
||||
$this->helper->check_guest_access_to_shared_items($shared, $file);
|
||||
($this->verifyAccessToItemWithin)($shared, $file);
|
||||
|
||||
// Store user download size
|
||||
($this->recordDownload)(
|
||||
@@ -40,6 +44,7 @@ class VisitorGetThumbnailController extends Controller
|
||||
user_id: $shared->user_id,
|
||||
);
|
||||
|
||||
// Finally download thumbnail
|
||||
return ($this->downloadThumbnail)($file, $shared->user_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user