Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 271fff1

Browse files
committed
Add hasLocaleWithLocaleCode function on Channel
1 parent 4cc999d commit 271fff1

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/Sylius/Component/Core/Model/Channel.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ public function hasLocale(LocaleInterface $locale): bool
180180
return $this->locales->contains($locale);
181181
}
182182

183+
public function hasLocaleWithLocaleCode(string $localeCode): bool
184+
{
185+
return !$this
186+
->locales
187+
->filter(function (LocaleInterface $locale) use ($localeCode): bool {
188+
return $locale->getCode() === $localeCode;
189+
})
190+
->isEmpty()
191+
;
192+
}
193+
183194
public function getCountries(): Collection
184195
{
185196
return $this->countries;

src/Sylius/Component/Locale/Model/LocalesAwareInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public function getLocales(): Collection;
2626

2727
public function hasLocale(LocaleInterface $locale): bool;
2828

29+
public function hasLocaleWithLocaleCode(string $localeCode): bool;
30+
2931
public function addLocale(LocaleInterface $locale): void;
3032

3133
public function removeLocale(LocaleInterface $locale): void;

0 commit comments

Comments
 (0)