Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasHermanek committed Oct 22, 2024
1 parent dd0d57c commit f9bff29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/Domain/Asset/AssetCopyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public function __construct(

public function buildDraftAssetCopy(Asset $asset, AssetLicence $assetLicence, bool $flush = true): Asset
{
// todo NOTIF!
// todo setup main file
$assetCopy = $asset->__copy();
$assetCopy->getAttributes()->setStatus(AssetStatus::Draft);
$this->trackCreation($assetCopy);
Expand Down
4 changes: 2 additions & 2 deletions src/Domain/AssetFile/AssetFileStatusManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function toProcessed(AssetFile $assetFile): AssetFile
/**
* @throws SerializerException
*/
public function toFailed(AssetFile $assetFile, AssetFileFailedType $failedType, Throwable $throwable): AssetFile
public function toFailed(AssetFile $assetFile, AssetFileFailedType $failedType, ?Throwable $throwable = null): AssetFile
{
$this->changeTransition($assetFile, AssetFileProcessStatus::Failed, $failedType);

Expand All @@ -88,7 +88,7 @@ public function toFailed(AssetFile $assetFile, AssetFileFailedType $failedType,
'Asset file (%s) process failed reason (%s). (%s',
(string) $assetFile->getId(),
$failedType->toString(),
$throwable->getMessage()
$throwable?->getMessage()
),
exception: $throwable
);
Expand Down
15 changes: 12 additions & 3 deletions src/Domain/Image/ImageCopyFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
use AnzuSystems\CoreDamBundle\Domain\Asset\AssetManager;
use AnzuSystems\CoreDamBundle\Domain\Asset\AssetPropertiesRefresher;
use AnzuSystems\CoreDamBundle\Domain\AssetFile\AssetFileCopyBuilder;
use AnzuSystems\CoreDamBundle\Domain\AssetFile\AssetFileStatusManager;
use AnzuSystems\CoreDamBundle\Domain\AssetFile\FileProcessor\AssetFileStorageOperator;
use AnzuSystems\CoreDamBundle\Domain\ImageFileOptimalResize\ImageFileOptimalResizeCopyBuilder;
use AnzuSystems\CoreDamBundle\Entity\Asset;
use AnzuSystems\CoreDamBundle\Entity\AssetSlot;
use AnzuSystems\CoreDamBundle\Event\Dispatcher\AssetFileEventDispatcher;
use AnzuSystems\CoreDamBundle\Exception\ForbiddenOperationException;
use AnzuSystems\CoreDamBundle\Messenger\Message\CopyAssetFileMessage;
use AnzuSystems\CoreDamBundle\Model\Dto\Image\AssetFileCopyResultDto;
use AnzuSystems\CoreDamBundle\Model\Dto\Image\ImageCopyDto;
use AnzuSystems\CoreDamBundle\Model\Enum\AssetFileCopyResult;
use AnzuSystems\CoreDamBundle\Model\Enum\AssetFileFailedType;
use AnzuSystems\CoreDamBundle\Repository\ImageFileRepository;
use AnzuSystems\CoreDamBundle\Traits\IndexManagerAwareTrait;
use AnzuSystems\CoreDamBundle\Traits\MessageBusAwareTrait;
Expand All @@ -42,6 +45,8 @@ public function __construct(
private readonly AssetFileCopyBuilder $assetFileCopyBuilder,
private readonly AssetPropertiesRefresher $refresher,
private readonly AssetManager $assetManager,
private readonly AssetFileEventDispatcher $assetFileEventDispatcher,
private readonly AssetFileStatusManager $assetFileStatusManager,
) {
}

Expand Down Expand Up @@ -107,8 +112,9 @@ public function copyAssetFiles(Asset $asset, Asset $copyAsset): void
throw $exception;
}

// todo send notification
// todo if copied dispatch message/mark as with file
foreach ($copyAsset->getSlots() as $slot) {
$this->assetFileEventDispatcher->dispatchAssetFileChanged($slot->getAssetFile());
}
}

private function prepareCopy(ImageCopyDto $copyDto): AssetFileCopyResultDto
Expand Down Expand Up @@ -173,7 +179,10 @@ private function copyAssetSlots(Asset $asset, Asset $copyAsset): void
continue;
}

// todo failed ... not found!
$this->assetFileStatusManager->toFailed(
$targetSlot->getAssetFile(),
AssetFileFailedType::Unknown
);
}
}

Expand Down

0 comments on commit f9bff29

Please sign in to comment.