Replaced TranslationCompletedListener
with AfterTranslateDto
across translation-related classes to streamline and enhance the job chaining logic. Added validation to ensure the provided class implements the required interface and included support for additional contextual data in the translation process. This change improves flexibility and simplifies the translation workflow.
This commit is contained in:
32
src/DTO/AfterTranslateDto.php
Normal file
32
src/DTO/AfterTranslateDto.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace KorElf\TranslateLaravel\DTO;
|
||||
|
||||
final readonly class AfterTranslateDto
|
||||
{
|
||||
/**
|
||||
* @param string $className The fully qualified class name (FQN) of a class that implements the TranslationCompletedListener interface.
|
||||
* @param array $data Additional data associated with the translation process.
|
||||
*/
|
||||
public function __construct(
|
||||
private string $className,
|
||||
private array $data = [],
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Get the fully qualified class name (FQN) of a class that implements the TranslationCompletedListener interface.
|
||||
*
|
||||
* @return class-string<\KorElf\TranslateLaravel\Contracts\TranslationCompletedListener>
|
||||
*/
|
||||
public function getClassName(): string
|
||||
{
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user