di['mod_service']('email'); // Preserve existing custom content and enabled/disabled preference. if ($email->getTemplateRepository()->findOneByActionCode($code) !== null) { return; } $source = file_get_contents(__DIR__ . '/templates/email/' . $code . '.html.twig'); if (!is_string($source) || !preg_match('/{%\s*block subject\s*%}(.*?){%\s*endblock\s*%}/s', $source, $subject) || !preg_match('/{%\s*block content\s*%}(.*?){%\s*endblock\s*%}/s', $source, $content)) { throw new \RuntimeException('Mail Gateway sender-mismatch template is missing or invalid'); } // This existing custom action code does not use the mod_* discovery convention. $email->templateCreate($code, trim($subject[1]), trim($content[1]), 1, 'mailgateway'); } }