Added the ability to upload pictures in the editor.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Services\DocumentationContent;
|
||||
|
||||
use App\Dto\Service\DocumentationContent\StorageDto;
|
||||
use App\Enums\Morph;
|
||||
use App\Exceptions\Services\DocumentationContent\StorageCommandException;
|
||||
use App\Services\Storage\StorageService;
|
||||
|
||||
final readonly class StorageCommand
|
||||
{
|
||||
public function __construct(
|
||||
private StorageService $storageService,
|
||||
) { }
|
||||
|
||||
|
||||
/**
|
||||
* @throws StorageCommandException
|
||||
*/
|
||||
public function execute(StorageDto $storageDto): void
|
||||
{
|
||||
foreach ($storageDto->getStorages() as $storage) {
|
||||
$storages = $this->storageService->getStoragesAndValidate($storage['storages'], Morph::DocumentationContent, $storage['documentationContent']->id);
|
||||
if (!$storages->isSuccess()) {
|
||||
throw new StorageCommandException($storages, 'Error when adding a file to storage: ' . $storages->getMessage());
|
||||
}
|
||||
|
||||
$this->storageService->saveAndDelete($storage['documentationContent'], $storages);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user