Added the ability to automatically translate simple text.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Services\ProjectTranslationServiceTextHash;
|
||||
|
||||
use App\Dto\Service\ProjectTranslationServiceTextHash\Hashes;
|
||||
use App\Dto\Service\ProjectTranslationServiceTextHash\HashStatusWaiting;
|
||||
use App\Enums\ProjectTranslationServiceHashes\Status;
|
||||
use App\Repositories\ProjectTranslationServiceTextHashRepository;
|
||||
|
||||
final readonly class CompletionChecker
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectTranslationServiceTextHashRepository $hashRepository,
|
||||
private ProjectTranslationServiceTextHashCommandHandler $commandHandler,
|
||||
) { }
|
||||
|
||||
public function execute(Hashes $hashesDto): HashStatusWaiting
|
||||
{
|
||||
$hashes = $this->hashRepository->getHashesByIds($hashesDto->getIds())->all();
|
||||
$hashStatusWaiting = new HashStatusWaiting();
|
||||
$hashSuccessIds = [];
|
||||
foreach ($hashes as $hash) {
|
||||
$dataHash = $hashesDto->getHash($hash->id);
|
||||
if ($dataHash === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$isWaiting = false;
|
||||
if ($hash->status === Status::Waiting && $hash->hash === $dataHash['hash'] && $hash->code === $dataHash['code']) {
|
||||
$isWaiting = true;
|
||||
$hashSuccessIds[] = $hash->id;
|
||||
}
|
||||
$hashStatusWaiting->add($hash->code, $isWaiting);
|
||||
}
|
||||
|
||||
$this->commandHandler->handleSetStatusById($hashSuccessIds, Status::Success);
|
||||
|
||||
return $hashStatusWaiting;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user