eZ\Publish\Core\Persistence\Legacy\Content\Language\Cache::getByLocale PHP Method

getByLocale() public method

Returns the Language with $languageCode from the cache.
public getByLocale ( string $languageCode ) : eZ\Publish\SPI\Persistence\Content\Language
$languageCode string
return eZ\Publish\SPI\Persistence\Content\Language
    public function getByLocale($languageCode)
    {
        if (!isset($this->mapByLocale[$languageCode])) {
            throw new NotFoundException('Language', $languageCode);
        }
        return $this->mapByLocale[$languageCode];
    }

Usage Example

 /**
  * Get language by Language Code (eg: eng-GB).
  *
  * @param string $languageCode
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If language could not be found by $languageCode
  *
  * @return \eZ\Publish\SPI\Persistence\Content\Language
  */
 public function loadByLanguageCode($languageCode)
 {
     $this->initializeCache();
     return $this->languageCache->getByLocale($languageCode);
 }