create filesystem abstraction
This commit is contained in:
parent
be2c51bfb7
commit
d59d444952
14 changed files with 44 additions and 64 deletions
|
|
@ -6,13 +6,13 @@ use App\Element\Element;
|
|||
use App\Element\ElementRepository;
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\FileUploader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class DeleteChildElement
|
||||
{
|
||||
public function __construct(
|
||||
private ElementRepository $elementRepository,
|
||||
private FileUploader $fileUploader,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +78,6 @@ class DeleteChildElement
|
|||
return;
|
||||
}
|
||||
|
||||
$this->fileUploader->delete($path);
|
||||
$this->filesystem->delete($path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Element\UseCases\GetElementPdf;
|
||||
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\StoredFileReader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class GetElementPdf
|
||||
{
|
||||
|
|
@ -11,7 +11,7 @@ class GetElementPdf
|
|||
|
||||
private const PDF_MIME_TYPE = 'application/pdf';
|
||||
|
||||
public function __construct(private StoredFileReader $storedFileReader)
|
||||
public function __construct(private Filesystem $filesystem)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class GetElementPdf
|
|||
}
|
||||
|
||||
$path = "element-pdfs/$request->folder/$request->fileName";
|
||||
$contents = $this->storedFileReader->read($path);
|
||||
$contents = $this->filesystem->read($path);
|
||||
if ($contents === null) {
|
||||
throw new NotFoundException('PDF not found');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use App\Element\ElementRepository;
|
|||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\FileToUpload;
|
||||
use App\Shared\Files\FileUploader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class UpdateIconImage
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ class UpdateIconImage
|
|||
|
||||
public function __construct(
|
||||
private ElementRepository $elementRepository,
|
||||
private FileUploader $fileUploader,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class UpdateIconImage
|
|||
mimeType: $request->fileMimeType,
|
||||
sizeBytes: $request->fileSizeBytes,
|
||||
);
|
||||
$path = $this->fileUploader->upload($iconImage, 'element-icons');
|
||||
$path = $this->filesystem->upload($iconImage, 'element-icons');
|
||||
$element->setIconImageUrl($path);
|
||||
|
||||
return $this->elementRepository->update($element);
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ use App\Element\Element;
|
|||
use App\Element\ElementRepository;
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\FileUploader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class UpdateIconImageUrl
|
||||
{
|
||||
public function __construct(
|
||||
private ElementRepository $elementRepository,
|
||||
private FileUploader $fileUploader,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +60,6 @@ class UpdateIconImageUrl
|
|||
return;
|
||||
}
|
||||
|
||||
$this->fileUploader->delete($path);
|
||||
$this->filesystem->delete($path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use App\Element\ElementRepository;
|
|||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\FileToUpload;
|
||||
use App\Shared\Files\FileUploader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class UpdateLongPdf
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@ class UpdateLongPdf
|
|||
|
||||
public function __construct(
|
||||
private ElementRepository $elementRepository,
|
||||
private FileUploader $fileUploader,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class UpdateLongPdf
|
|||
mimeType: $request->fileMimeType,
|
||||
sizeBytes: $request->fileSizeBytes,
|
||||
);
|
||||
$path = $this->fileUploader->upload($pdf, 'element-pdfs/long');
|
||||
$path = $this->filesystem->upload($pdf, 'element-pdfs/long');
|
||||
$element->setLongPdfPath($path);
|
||||
|
||||
return $this->elementRepository->update($element);
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ use App\Element\Element;
|
|||
use App\Element\ElementRepository;
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\FileUploader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class UpdateLongPdfPath
|
||||
{
|
||||
public function __construct(
|
||||
private ElementRepository $elementRepository,
|
||||
private FileUploader $fileUploader,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +60,6 @@ class UpdateLongPdfPath
|
|||
return;
|
||||
}
|
||||
|
||||
$this->fileUploader->delete($path);
|
||||
$this->filesystem->delete($path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use App\Element\ElementRepository;
|
|||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\FileToUpload;
|
||||
use App\Shared\Files\FileUploader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class UpdateShortPdf
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@ class UpdateShortPdf
|
|||
|
||||
public function __construct(
|
||||
private ElementRepository $elementRepository,
|
||||
private FileUploader $fileUploader,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class UpdateShortPdf
|
|||
mimeType: $request->fileMimeType,
|
||||
sizeBytes: $request->fileSizeBytes,
|
||||
);
|
||||
$path = $this->fileUploader->upload($pdf, 'element-pdfs/short');
|
||||
$path = $this->filesystem->upload($pdf, 'element-pdfs/short');
|
||||
$element->setShortPdfPath($path);
|
||||
|
||||
return $this->elementRepository->update($element);
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ use App\Element\Element;
|
|||
use App\Element\ElementRepository;
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Exceptions\NotFoundException;
|
||||
use App\Shared\Files\FileUploader;
|
||||
use App\Shared\Files\Filesystem;
|
||||
|
||||
class UpdateShortPdfPath
|
||||
{
|
||||
public function __construct(
|
||||
private ElementRepository $elementRepository,
|
||||
private FileUploader $fileUploader,
|
||||
private Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +60,6 @@ class UpdateShortPdfPath
|
|||
return;
|
||||
}
|
||||
|
||||
$this->fileUploader->delete($path);
|
||||
$this->filesystem->delete($path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue