* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Employee; use Language; use PrestaShop\PrestaShop\Adapter\LegacyContext; use PrestaShop\PrestaShop\Core\Employee\FormLanguageChangerInterface; /** * Class FormLanguageChanger is responsible for changing the language, * which is used in forms by the employee. * It is not the language in which form texts are translated, but rather * the language, which is selected by default in the translatable fields. */ final class FormLanguageChanger implements FormLanguageChangerInterface { /** * @var LegacyContext */ private $legacyContext; /** * @param LegacyContext $legacyContext */ public function __construct(LegacyContext $legacyContext) { $this->legacyContext = $legacyContext; } /** * {@inheritdoc} */ public function changeLanguageInCookies($languageIsoCode) { $this->legacyContext->getContext()->cookie->employee_form_lang = (int) Language::getIdByIso($languageIsoCode); $this->legacyContext->getContext()->cookie->write(); } }