handle nullable pdf params
This commit is contained in:
parent
9126b0e968
commit
8c8ee4c050
3 changed files with 18 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Element\UseCases\GetElementPdf;
|
||||
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
|
|
@ -16,10 +17,19 @@ class GetElementPdf
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequestException
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
public function execute(GetElementPdfRequest $request): GetElementPdfResult
|
||||
{
|
||||
if ($request->folder === null) {
|
||||
throw new BadRequestException('folder is required');
|
||||
}
|
||||
|
||||
if ($request->fileName === null) {
|
||||
throw new BadRequestException('fileName is required');
|
||||
}
|
||||
|
||||
if (!$this->isAllowedPdfFolder($request->folder)) {
|
||||
throw new NotFoundException('PDF not found');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue