/** * Isolate locale value from parameters * * @param array $parameters * @return null|string */ private function extractLocaleFromParameters(&$parameters = []) { $locale = null; if (!is_array($parameters)) { $locale = $this->locale->get($parameters); // If locale is the only parameter, we make sure the 'real' parameters is flushed if ($locale == $parameters) { $parameters = []; } return $locale; } if (!array_key_exists($this->placeholder, $parameters)) { return $this->locale->get(); } $locale = $this->locale->get($parameters[$this->placeholder]); // If locale parameter is not a 'real' parameters, we ignore the passed locale and use the active one // The 'wrong' parameter will be used without key if ($locale != $parameters[$this->placeholder]) { $parameters[] = $parameters[$this->placeholder]; } unset($parameters[$this->placeholder]); return $locale; }