[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 {
services: function (extensions) {
return extensions.map(registerExtension);
}
services: registerExtension;
};
}

View File

@ -16,7 +16,7 @@ define(
// Track which extension categories have already been registered.
// Exceptions will be thrown if the same extension category is
// registered twice.
var registeredCategories = {},
var registeredCategories = {};
function identify(category, extension, index) {
var name = extension.key ?
@ -68,11 +68,16 @@ define(
category,
" more than once. Ignoring all but first set."
].join(""));
} else if (customRegistrars[category]) {
return customRegistrars[category](extensions);
} else {
extensions.forEach(registerExtension);
registerExtensionArraysForCategory(category, names);
// 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 {
extensions.forEach(registerExtension);
registerExtensionArraysForCategory(category, names);
}
registeredCategories[category] = true;
return true;
}