Explorar o código

Revert "Add warning message to PluginCollection#get() when plugin is not loaded."

This reverts commit decc5911
Maciej Gołaszewski %!s(int64=7) %!d(string=hai) anos
pai
achega
6dc04beb0a

+ 1 - 26
packages/ckeditor5-core/src/plugincollection.js

@@ -76,32 +76,7 @@ export default class PluginCollection {
 	 * @returns {module:core/plugin~PluginInterface}
 	 */
 	get( key ) {
-		const plugin = this._plugins.get( key );
-
-		if ( !plugin ) {
-			/**
-			 * The plugin is not loaded and could not be obtained.
-			 *
-			 * Plugin classes (constructors) need to be provided to the editor and must be loaded before they can be obtained from
-			 * the plugin collection.
-			 * This is usually done in CKEditor 5 builds by setting the {@link module:core/editor/editor~Editor.builtinPlugins}
-			 * property.
-			 *
-			 * @error plugincollection-plugin-not-loaded
-			 * @param {String} plugin The name of the plugin which is not loaded.
-			 */
-			const warnMessage = 'plugincollection-plugin-not-loaded: The requested plugin is not loaded.';
-
-			let pluginName = key;
-
-			if ( typeof key == 'function' ) {
-				pluginName = key.pluginName || key.name;
-			}
-
-			log.warn( warnMessage, { plugin: pluginName } );
-		}
-
-		return plugin;
+		return this._plugins.get( key );
 	}
 
 	/**

+ 0 - 53
packages/ckeditor5-core/tests/plugincollection.js

@@ -448,59 +448,6 @@ describe( 'PluginCollection', () => {
 					expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
 				} );
 		} );
-
-		it( 'warns if plugin cannot be retrieved by name', () => {
-			const logSpy = testUtils.sinon.stub( log, 'warn' );
-
-			const plugins = new PluginCollection( editor, availablePlugins );
-
-			return plugins.load( [] ).then( () => {
-				const plugin = plugins.get( 'foo' );
-
-				expect( plugin ).to.be.undefined;
-
-				expect( logSpy.calledOnce ).to.equal( true );
-				expect( logSpy.firstCall.args[ 0 ] ).to.match( /^plugincollection-plugin-not-loaded:/ );
-				expect( logSpy.firstCall.args[ 1 ] ).to.deep.equal( { plugin: 'foo' } );
-			} );
-		} );
-
-		it( 'warns if plugin cannot be retrieved by class', () => {
-			class SomePlugin extends Plugin {}
-			SomePlugin.pluginName = 'foo';
-
-			const logSpy = testUtils.sinon.stub( log, 'warn' );
-
-			const plugins = new PluginCollection( editor, availablePlugins );
-
-			return plugins.load( [] ).then( () => {
-				const plugin = plugins.get( SomePlugin );
-
-				expect( plugin ).to.be.undefined;
-
-				expect( logSpy.calledOnce ).to.equal( true );
-				expect( logSpy.firstCall.args[ 0 ] ).to.match( /^plugincollection-plugin-not-loaded:/ );
-				expect( logSpy.firstCall.args[ 1 ] ).to.deep.equal( { plugin: 'foo' } );
-			} );
-		} );
-
-		it( 'logs function (class) name if plugin cannot be retrieved by class', () => {
-			class SomePlugin extends Plugin {}
-
-			const logSpy = testUtils.sinon.stub( log, 'warn' );
-
-			const plugins = new PluginCollection( editor, availablePlugins );
-
-			return plugins.load( [] ).then( () => {
-				const plugin = plugins.get( SomePlugin );
-
-				expect( plugin ).to.be.undefined;
-
-				expect( logSpy.calledOnce ).to.equal( true );
-				expect( logSpy.firstCall.args[ 0 ] ).to.match( /^plugincollection-plugin-not-loaded:/ );
-				expect( logSpy.firstCall.args[ 1 ] ).to.deep.equal( { plugin: 'SomePlugin' } );
-			} );
-		} );
 	} );
 
 	describe( 'destroy()', () => {