Update LocalizedContentInterface to allow removal of locales

This commit is contained in:
2025-01-15 13:18:50 +01:00
parent d539259b11
commit 481950093f
2 changed files with 19 additions and 0 deletions
@@ -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.
*/
+12
View File
@@ -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;