@universis/dining
Version:
Universis api for dining
45 lines (41 loc) • 1.58 kB
JavaScript
;Object.defineProperty(exports, "__esModule", { value: true });exports.MailTemplateService = void 0;var _common = require("@themost/common");
var _mailer = require("@themost/mailer");
var _path = _interopRequireDefault(require("path"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
/**
* @interface ExtraTemplateConfiguration
* @property {string} name
* @property {string} path
*/
/**
*
*/
class MailTemplateService extends _common.ApplicationService {
constructor(app) {
super(app);
/**
* @type {Array<ExtraTemplateConfiguration>}
*/
this.extraTemplates = [];
this.install();
}
install() {
const MailerHelperPrototype = Object.getPrototypeOf((0, _mailer.getMailer)(null));
const thisService = this;
Object.defineProperty(MailerHelperPrototype, 'getTemplatePath', {
configurable: true,
enumerable: true,
get() {
return function (template, extension) {
const extraTemplate = thisService.extraTemplates.find(item => {
return item.name === template;
});
if (extraTemplate != null) {
return extraTemplate.path;
}
// get execution path
const executionPath = thisService.getApplication().getConfiguration().getExecutionPath();
return _path.default.resolve(executionPath, `./templates/mails/${template}/html.${extension}`);
};
} });
}}exports.MailTemplateService = MailTemplateService;
//# sourceMappingURL=MailTemplateService.js.map