diff --git a/src/Entity/Interface/LocalizedContentInterface.php b/src/Entity/Interface/LocalizedContentInterface.php index 4ae11c3..0dc6338 100644 --- a/src/Entity/Interface/LocalizedContentInterface.php +++ b/src/Entity/Interface/LocalizedContentInterface.php @@ -13,6 +13,8 @@ use Gedmo\Translatable\Translatable; */ interface LocalizedContentInterface extends Translatable { + public function getId(): ?int; + /** * Set the locale of the working content for translations. */ @@ -28,6 +30,11 @@ interface LocalizedContentInterface extends Translatable */ public function addLocale(string $locale): static; + /** + * Remove from the list of available translation locales. + */ + public function removeLocale(string $locale): static; + /** * Set the list of available translation locales. */ diff --git a/src/Entity/Trait/LocalizedContent.php b/src/Entity/Trait/LocalizedContent.php index e2c9628..4a5d7dd 100644 --- a/src/Entity/Trait/LocalizedContent.php +++ b/src/Entity/Trait/LocalizedContent.php @@ -32,6 +32,18 @@ trait LocalizedContent return $this; } + public function removeLocale(string $locale): static + { + $needle = $locale; + + $this->locales = [...\array_filter($this->locales, function (string $locale) use ($needle) { + return $locale !== $needle; + })]; + + return $this; + } + + public function setLocales(array $locales): static { $this->locales = $locales;