/** * @class Ext.ComponentManager *

Provides a registry of all Components (instances of {@link Ext.Component} or any subclass * thereof) on a page so that they can be easily accessed by {@link Ext.Component component} * {@link Ext.Component#id id} (see {@link #get}, or the convenience method {@link Ext#getCmp Ext.getCmp}).

*

This object also provides a registry of available Component classes * indexed by a mnemonic code known as the Component's {@link Ext.Component#xtype xtype}. * The xtype provides a way to avoid instantiating child Components * when creating a full, nested config object for a complete Ext page.

*

A child Component may be specified simply as a config object * as long as the correct {@link Ext.Component#xtype xtype} is specified so that if and when the Component * needs rendering, the correct type can be looked up for lazy instantiation.

*

For a list of all available {@link Ext.Component#xtype xtypes}, see {@link Ext.Component}.

* @singleton */ Ext.define('Ext.ComponentManager', { extend: 'Ext.AbstractManager', alternateClassName: 'Ext.ComponentMgr', singleton: true, typeName: 'xtype', /** * Creates a new Component from the specified config object using the * config object's xtype to determine the class to instantiate. * @param {Object} config A configuration object for the Component you wish to create. * @param {String} defaultType (optional) The xtype to use if the config object does not * contain a xtype. (Optional if the config contains a xtype). * @return {Ext.Component} The newly instantiated Component. */ create: function(component, defaultType){ if (typeof component == 'string') { return Ext.widget(component); } if (component.isComponent) { return component; } return Ext.widget(component.xtype || defaultType, component); }, registerType: function(type, cls) { this.types[type] = cls; cls[this.typeName] = type; cls.prototype[this.typeName] = type; } });