mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-07 16:24:43 +03:00
Create missed templates at "operator/mail-template" page
This commit is contained in:
parent
8f346ae0b7
commit
96724464e2
@ -186,21 +186,23 @@ class MailTemplateController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* Loads mail template.
|
* Loads mail template.
|
||||||
*
|
*
|
||||||
* It's just a wrapper for {@link mail_template_load()} function which
|
* It's just a wrapper for {@link \Mibew\Mail\Template::loadByName()}
|
||||||
* throws an exception if a template cannot be loaded.
|
* method which creates an empty template if it does not exist.
|
||||||
*
|
*
|
||||||
* @param string $name Machine name of the template
|
* @param string $name Machine name of the template
|
||||||
* @param string $locale Locale code which should be used for template
|
* @param string $locale Locale code which should be used for template
|
||||||
* loading.
|
* loading.
|
||||||
* @return array Mail template.
|
* @return \Mibew\Mail\Template Mail template.
|
||||||
* @throws \RuntimeException If the template cannot be loaded.
|
|
||||||
*/
|
*/
|
||||||
protected function loadMailTemplate($name, $locale)
|
protected function loadMailTemplate($name, $locale)
|
||||||
{
|
{
|
||||||
$template = MailTemplate::loadByName($name, $locale);
|
$template = MailTemplate::loadByName($name, $locale);
|
||||||
|
|
||||||
if (!$template) {
|
if (!$template) {
|
||||||
throw new \RuntimeException(sprintf('Cannot load "%s" mail template', $name));
|
// Create an empty template. It can be helpful in the case a new
|
||||||
|
// template is added to the system.
|
||||||
|
$template = new MailTemplate($name, $locale);
|
||||||
|
$template->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $template;
|
return $template;
|
||||||
|
Loading…
Reference in New Issue
Block a user