firing new third type of hook, static. New hook: static:app.load, closed #1812

v1.18.x
Julian Lam 11 years ago
parent eea987d8dd
commit 0bad6198d4

@ -357,19 +357,6 @@ var fs = require('fs'),
var hookType = hook.split(':')[0];
switch (hookType) {
case 'filter':
if (hook === 'filter:app.load') {
// Special case for this hook, as arguments passed in are always the same
async.each(hookList, function(hookObj, next) {
if (hookObj.method) {
hookObj.method.apply(Plugins, args.concat(next));
}
}, function(err) {
callback(err);
});
return;
}
async.reduce(hookList, args, function(value, hookObj, next) {
if (hookObj.method) {
if (!hookObj.hasOwnProperty('callbacked') || hookObj.callbacked === true) {
@ -417,7 +404,7 @@ var fs = require('fs'),
async.each(hookList, function(hookObj, next) {
/*
Backwards compatibility block for v0.5.0
Remove this once NodeBB enters v0.5.0-1
Remove this once NodeBB enters v0.6.0-1
*/
if (hook === 'action:app.load') {
deprecationWarn.push(hookObj.id);
@ -436,10 +423,10 @@ var fs = require('fs'),
}, function() {
/*
Backwards compatibility block for v0.5.0
Remove this once NodeBB enters v0.5.0-1
Remove this once NodeBB enters v0.6.0-1
*/
if (deprecationWarn.length) {
winston.warn('[plugins] The `action:app.load` hook is deprecated in favour of `filter:app.load`, please notify the developers of the following plugins:');
winston.warn('[plugins] The `action:app.load` hook is deprecated in favour of `static:app.load`, please notify the developers of the following plugins:');
for(var x=0,numDeprec=deprecationWarn.length;x<numDeprec;x++) {
process.stdout.write(' * ' + deprecationWarn[x] + '\n');
}
@ -447,6 +434,15 @@ var fs = require('fs'),
/* End backwards compatibility block */
});
break;
case 'static':
async.each(hookList, function(hookObj, next) {
if (hookObj.method) {
hookObj.method.apply(Plugins, args.concat(next));
}
}, function(err) {
callback(err);
});
break;
default:
// Do nothing...
break;

@ -188,7 +188,7 @@ module.exports = function(app, middleware) {
userRoutes(router, middleware, controllers);
groupRoutes(router, middleware, controllers);
plugins.fireHook('filter:app.load', router, middleware, controllers, function() {
plugins.fireHook('static:app.load', router, middleware, controllers, function() {
app.use(relativePath, router);
app.use(relativePath, express.static(path.join(__dirname, '../../', 'public'), {

Loading…
Cancel
Save