-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntityTranslatorInterface.php
More file actions
47 lines (36 loc) · 1.71 KB
/
EntityTranslatorInterface.php
File metadata and controls
47 lines (36 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace Tmi\TranslationBundle\Translation;
use Tmi\TranslationBundle\Doctrine\Model\TranslatableInterface;
use Tmi\TranslationBundle\Translation\Args\TranslationArgs;
interface EntityTranslatorInterface
{
public function translate(TranslatableInterface $entity, string $locale): TranslatableInterface;
/**
* Translates the entity and persists the result via the EntityManager.
*/
public function translateAndPersist(TranslatableInterface $entity, string $locale): TranslatableInterface;
/**
* Returns an existing translation or creates, persists and returns a new one.
*/
public function getOrTranslate(TranslatableInterface $entity, string $locale): TranslatableInterface;
/**
* Process translation for an entity, embedded object, or property value.
*
* Exposed so handlers may recursively translate sub-objects through the
* orchestrator's handler chain.
*
* @param TranslationArgs $args contains the data to translate, source/target locales, and optional parent context
*
* @return mixed translated entity (TranslatableInterface), embedded object, or scalar property value
*/
public function processTranslation(TranslationArgs $args): mixed;
/** Called after an entity is loaded. */
public function afterLoad(TranslatableInterface $entity): void;
/** Called before an entity is persisted. */
public function beforePersist(TranslatableInterface $entity): void;
/** Called before an entity is updated. */
public function beforeUpdate(TranslatableInterface $entity): void;
/** Called before an entity is removed. */
public function beforeRemove(TranslatableInterface $entity): void;
}