/**
* @param Translator $translator
* @return string|NULL
*/
public function resolve(Translator $translator)
{
if (!$this->session->isStarted() && $this->httpResponse->isSent()) {
trigger_error("The advice of session locale resolver is required but the session has not been started and headers had been already sent. " . "Either start your sessions earlier or disabled the SessionResolver.", E_USER_WARNING);
return NULL;
}
if (empty($this->localeSession->locale)) {
return NULL;
}
$short = array_map(function ($locale) {
return substr($locale, 0, 2);
}, $translator->getAvailableLocales());
if (!in_array(substr($this->localeSession->locale, 0, 2), $short, TRUE)) {
return NULL;
}
return $this->localeSession->locale;
}