2021-04-23 16:19:18 +03:00
|
|
|
// @TODO: refactor constructor pattern so we don't have to require config here?
|
2021-04-26 16:38:57 +03:00
|
|
|
const config = require('./shared/config');
|
|
|
|
const {events} = require('./server/lib/common');
|
|
|
|
const themeEngine = require('./frontend/services/theme-engine');
|
2021-04-23 16:19:18 +03:00
|
|
|
|
|
|
|
class Bridge {
|
|
|
|
constructor() {
|
2021-04-26 13:53:15 +03:00
|
|
|
/**
|
|
|
|
* When locale changes, we reload theme translations
|
|
|
|
* @deprecated: the term "lang" was deprecated in favour of "locale" publicly 4.0
|
|
|
|
*/
|
|
|
|
events.on('settings.lang.edited', () => {
|
|
|
|
this.getActiveTheme().initI18n();
|
|
|
|
});
|
2021-04-23 16:19:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
getActiveTheme() {
|
|
|
|
return themeEngine.getActive();
|
|
|
|
}
|
|
|
|
|
|
|
|
getFrontendApiVersion() {
|
|
|
|
if (this.getActiveTheme()) {
|
|
|
|
return this.getActiveTheme().engine('ghost-api');
|
|
|
|
} else {
|
|
|
|
return config.get('api:versions:default');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const bridge = new Bridge();
|
|
|
|
|
|
|
|
module.exports = bridge;
|