Add warning when using the 'modifyClass' plugin API after it's been cached in the container

This commit is contained in:
Régis Hanol 2017-08-08 20:07:35 +02:00
parent 5324c9817f
commit 15fa27a1ff
1 changed files with 4 additions and 0 deletions

View File

@ -55,6 +55,10 @@ class PluginApi {
* ``` * ```
**/ **/
modifyClass(resolverName, changes) { modifyClass(resolverName, changes) {
if (this.container.cache[resolverName]) {
console.warn(`"${resolverName}" was already cached in the container. Changes won't be applied.`);
}
const klass = this.container.factoryFor(resolverName); const klass = this.container.factoryFor(resolverName);
klass.class.reopen(changes); klass.class.reopen(changes);
return klass; return klass;