Neos\Flow\I18n\LocaleCollection::addLocale PHP Method

addLocale() public method

Adds a locale to the collection.
public addLocale ( Locale $locale ) : boolean
$locale Locale The Locale to be inserted
return boolean FALSE when same locale was already inserted before
    public function addLocale(Locale $locale)
    {
        if (isset($this->localeCollection[(string) $locale])) {
            return false;
        }
        // We need to invalidate the parent's array as it could be inaccurate
        $this->localeParentCollection = [];
        $this->localeCollection[(string) $locale] = $locale;
        return true;
    }

Usage Example

 /**
  * @test
  */
 public function returnsNullWhenNoParentLocaleCouldBeFound()
 {
     foreach ($this->locales as $locale) {
         $this->localeCollection->addLocale($locale);
     }
     $this->assertNull($this->localeCollection->getParentLocaleOf(new I18n\Locale('sv')));
     $this->assertNull($this->localeCollection->getParentLocaleOf($this->locales[0]));
 }
All Usage Examples Of Neos\Flow\I18n\LocaleCollection::addLocale