refactor: move plugin hook methods to plugin.hooks.*

This commit is contained in:
Julian Lam
2020-11-20 16:06:26 -05:00
parent 3b1c03ed50
commit 6e2da9966e
136 changed files with 550 additions and 541 deletions

View File

@@ -30,7 +30,7 @@ admin.getAreas = async function () {
{ name: 'Group Page (Right)', template: 'groups/details.tpl', location: 'right' },
];
const areas = await plugins.fireHook('filter:widgets.getAreas', defaultAreas);
const areas = await plugins.hooks.fire('filter:widgets.getAreas', defaultAreas);
areas.push({ name: 'Draft Zone', template: 'global', location: 'drafts' });
const areaData = await Promise.all(areas.map(area => index.getArea(area.template, area.location)));
@@ -42,7 +42,7 @@ admin.getAreas = async function () {
async function getAvailableWidgets() {
const [availableWidgets, adminTemplate] = await Promise.all([
plugins.fireHook('filter:widgets.getWidgets', []),
plugins.hooks.fire('filter:widgets.getWidgets', []),
renderAdminTemplate(),
]);
availableWidgets.forEach(function (w) {

View File

@@ -62,7 +62,7 @@ async function renderWidget(widget, uid, options) {
const userLang = config.userLang || meta.config.defaultLang || 'en-GB';
const templateData = _.assign({ }, options.templateData, { config: config });
const data = await plugins.fireHook('filter:widget.render:' + widget.widget, {
const data = await plugins.hooks.fire('filter:widget.render:' + widget.widget, {
uid: uid,
area: options,
templateData: templateData,
@@ -175,7 +175,7 @@ widgets.reset = async function () {
];
const [areas, drafts] = await Promise.all([
plugins.fireHook('filter:widgets.getAreas', defaultAreas),
plugins.hooks.fire('filter:widgets.getAreas', defaultAreas),
widgets.getArea('global', 'drafts'),
]);