public static object|null
getTemplate
(mixed $key, mixed $language)
/**
* Get a specific mail template
*
* @param string $key Template identifier
* @param string $language Language code of the template
*
* @return object|null An object with the data of the mail, or null if the template not found in the db.
*
* @since 4.0.0
*/
public static function getTemplate($key, $language)
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('*')->from($db->quoteName('#__mail_templates'))->where($db->quoteName('template_id') . ' = :key')->whereIn($db->quoteName('language'), ['', $language], ParameterType::STRING)->order($db->quoteName('language') . ' DESC')->bind(':key', $key);
$db->setQuery($query);
$mail = $db->loadObject();
if ($mail) {
$mail->params = new Registry($mail->params);
}
return $mail;
}