controller refactoring part 24

This commit is contained in:
Peter Papp
2021-07-21 18:46:55 +02:00
parent 54f1f4c9a8
commit 6d8a7a429c
29 changed files with 561 additions and 209 deletions

View File

@@ -5,7 +5,8 @@ use Domain\Files\Models\File;
use Domain\Sharing\Models\Share;
use Domain\Folders\Models\Folder;
use Illuminate\Support\Collection;
use Support\Services\HelperService;
use Domain\Sharing\Actions\ProtectShareRecordAction;
use Domain\Sharing\Actions\VerifyAccessToItemAction;
/**
* Browse shared folder
@@ -13,7 +14,8 @@ use Support\Services\HelperService;
class VisitorBrowseFolderContentController
{
public function __construct(
public HelperService $helper,
private ProtectShareRecordAction $protectShareRecord,
private VerifyAccessToItemAction $verifyAccessToItem,
) {
}
@@ -22,10 +24,10 @@ class VisitorBrowseFolderContentController
Share $shared,
): Collection {
// Check ability to access protected share record
$this->helper->check_protected_share_record($shared);
($this->protectShareRecord)($shared);
// Check if user can get directory
$this->helper->check_item_access($id, $shared);
($this->verifyAccessToItem)($id, $shared);
// Get files and folders
$folders = Folder::where('user_id', $shared->user_id)

View File

@@ -7,8 +7,8 @@ use Domain\Files\Models\File;
use Domain\Sharing\Models\Share;
use Domain\Folders\Models\Folder;
use Illuminate\Support\Collection;
use Support\Services\HelperService;
use App\Http\Controllers\Controller;
use Domain\Sharing\Actions\ProtectShareRecordAction;
/**
* Visitor search shared files
@@ -16,7 +16,7 @@ use App\Http\Controllers\Controller;
class VisitorSearchFilesAndFoldersController extends Controller
{
public function __construct(
public HelperService $helper,
private ProtectShareRecordAction $protectShareRecord,
) {
}
@@ -25,7 +25,7 @@ class VisitorSearchFilesAndFoldersController extends Controller
Share $shared,
): Collection {
// Check ability to access protected share record
$this->helper->check_protected_share_record($shared);
($this->protectShareRecord)($shared);
$query = remove_accents(
$request->input('query')