1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/wizard/lib/initialize/inject-objects.js.es6

59 Zeilen
1,9 KiB
Text

2022-03-16 12:33:34 +01:00
export default {
run(app) {
// siteSettings must always be registered first
if (!app.hasRegistration("site-settings:main")) {
const siteSettings = app.SiteSettings;
app.register("site-settings:main", siteSettings, { instantiate: false });
}
2022-03-16 12:33:34 +01:00
const Store = requirejs("discourse/services/store").default;
const Site = requirejs(
"discourse/plugins/discourse-custom-wizard/wizard/models/site"
).default;
const Session = requirejs("discourse/models/session").default;
const RestAdapter = requirejs("discourse/adapters/rest").default;
const messageBus = requirejs("message-bus-client").default;
const sniffCapabilites = requirejs(
"discourse/pre-initializers/sniff-capabilities"
).default;
2022-03-16 12:33:34 +01:00
const site = Site.current();
const session = Session.current();
const registrations = [
["message-bus:main", messageBus, false],
["site:main", site, false],
["session:main", session, false],
["service:store", Store, true],
2022-06-15 08:59:09 +02:00
["adapter:rest", RestAdapter, true],
2022-03-16 12:33:34 +01:00
];
2022-06-15 08:59:09 +02:00
registrations.forEach((registration) => {
2022-03-16 12:33:34 +01:00
if (!app.hasRegistration(registration[0])) {
2022-06-15 08:59:09 +02:00
app.register(registration[0], registration[1], {
instantiate: registration[2],
});
2022-03-16 12:33:34 +01:00
}
});
const targets = ["controller", "component", "route", "model", "adapter"];
targets.forEach((t) => {
app.inject(t, "appEvents", "service:app-events");
app.inject(t, "store", "service:store");
app.inject(t, "site", "site:main");
});
2022-03-16 12:33:34 +01:00
targets.concat("service").forEach((t) => {
app.inject(t, "session", "session:main");
app.inject(t, "messageBus", "message-bus:main");
app.inject(t, "siteSettings", "site-settings:main");
2022-03-16 12:33:34 +01:00
});
if (!app.hasRegistration("capabilities:main")) {
sniffCapabilites.initialize(null, app);
}
site.set("can_create_tag", false);
2022-06-15 08:59:09 +02:00
},
};