Update LocalizedContentInterface to allow removal of locales
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user