[Framework] Simplify custom registration

Handle the iteration over extensions which have a
custom registration mechanism (directives, services)
at the same level that general registration is handled.
WTD-518.
This commit is contained in:
Victor Woeltjen 2014-11-04 08:06:44 -08:00
parent 00de789f5e
commit d8eb72621b
2 changed files with 11 additions and 8 deletions

View File

@ -45,9 +45,7 @@ define(
} }
return { return {
services: function (extensions) { services: registerExtension;
return extensions.map(registerExtension);
}
}; };
} }

View File

@ -16,7 +16,7 @@ define(
// Track which extension categories have already been registered. // Track which extension categories have already been registered.
// Exceptions will be thrown if the same extension category is // Exceptions will be thrown if the same extension category is
// registered twice. // registered twice.
var registeredCategories = {}, var registeredCategories = {};
function identify(category, extension, index) { function identify(category, extension, index) {
var name = extension.key ? var name = extension.key ?
@ -68,11 +68,16 @@ define(
category, category,
" more than once. Ignoring all but first set." " more than once. Ignoring all but first set."
].join("")); ].join(""));
} else if (customRegistrars[category]) { } else {
return customRegistrars[category](extensions); // Register all extensions. Use custom registration
// code for services, directives, etc; otherwise,
// just register them under generic names.
if (customRegistrars[category]) {
extensions.forEach(customRegistrars[category]);
} else { } else {
extensions.forEach(registerExtension); extensions.forEach(registerExtension);
registerExtensionArraysForCategory(category, names); registerExtensionArraysForCategory(category, names);
}
registeredCategories[category] = true; registeredCategories[category] = true;
return true; return true;
} }