'staff_3', 'requestData' => [ 'template' => [ 'validation' => DataValidator::notBlank()->length(LengthConfig::MIN_LENGTH_TEMPLATE), 'error' => ERRORS::INVALID_TEMPLATE ], 'language' => [ 'validation' => DataValidator::oneOf(DataValidator::in(Language::getSupportedLanguages()), DataValidator::nullType()), 'error' => ERRORS::INVALID_LANGUAGE ], ] ]; } public function handler() { $templateType = Controller::request('template'); $language = Controller::request('language'); $mailTemplate = MailTemplate::findOne(' language = ? AND template = ?', [$language, $templateType]); if($mailTemplate->isNull()) { throw new RequestException(ERRORS::INVALID_TEMPLATE); } $mailTexts = MailTexts::getTexts()[$language][$templateType]; $mailTemplate->subject = $mailTexts[0]; $mailTemplate->text1 = (array_key_exists(1, $mailTexts)) ? $mailTexts[1] : ''; $mailTemplate->text2 = (array_key_exists(2, $mailTexts)) ? $mailTexts[2] : ''; $mailTemplate->text3 = (array_key_exists(3, $mailTexts)) ? $mailTexts[3] : ''; $mailTemplate->store(); Response::respondSuccess(); } }