For up to date documentation and features, visit http://docs.sencha.com/ext-js/4-0

## Sencha Documentation

# Ext.ClassManager

Ext.ClassManager manages all classes and handles mapping from string class name to actual class objects throughout the whole framework. It is not generally accessed directly, rather through these convenient shorthands:

- Ext.define
- Ext.create
- Ext.widget
- Ext.getClass
- Ext.getClassName

Defined By

### Methods

Ext.ClassManager
view source
create( String className, Object data, Function createdFn) : Ext.Base
Defines a class. This is usually invoked via the alias Ext.define Ext.ClassManager.create('My.awesome.Class', { ...

Defines a class. This is usually invoked via the alias Ext.define

    Ext.ClassManager.create('My.awesome.Class', {
        someProperty: 'something',
        someMethod: function() { ... }
        ...

    }, function() {
        alert('Created!');
        alert(this === My.awesome.Class); // alerts true

        var myInstance = new this();
    });

### Parameters

- className : String

  The class name to create in string dot-namespaced format, for example: 'My.very.awesome.Class', 'FeedViewer.plugin.CoolPager' It is highly recommended to follow this simple convention:

  - The root and the class name are 'CamelCased'
  - Everything else is lower-cased
- data : Object

  The key - value pairs of properties to apply to this class. Property names can be of any valid strings, except those in the reserved listed below:

  - `mixins`
  - `statics`
  - `config`
  - `alias`
  - `self`
  - `singleton`
  - `alternateClassName`
- createdFn : Function

  Optional callback to execute after the class is created, the execution scope of which (`this`) will be the newly created class itself.

### Returns

- Ext.Base

Ext.ClassManager
view source
get( String name) : Class

Retrieve a class by its name.

Retrieve a class by its name.

### Parameters

- name : String

### Returns

- Class

  class

Ext.ClassManager
view source
getAliasesByName( String name) : Array

Get the aliases of a class by the class name

Get the aliases of a class by the class name

### Parameters

- name : String

### Returns

- Array

  aliases

Ext.ClassManager
view source
getByAlias( String alias) : Class

Get a reference to the class by its alias.

Get a reference to the class by its alias.

### Parameters

- alias : String

### Returns

- Class

  class

Ext.ClassManager
view source
getClass( Object object) : Class
Get the class of the provided object; returns null if it's not an instance of any class created with Ext.define. This...

Get the class of the provided object; returns null if it's not an instance of any class created with Ext.define. This is usually invoked by the shorthand Ext.getClass

    var component = new Ext.Component();

    Ext.ClassManager.getClass(component); // returns Ext.Component

### Parameters

- object : Object

### Returns

- Class

  class

Ext.ClassManager
view source
getDisplayName( Mixed object) : void

### Parameters

- object : Mixed

### Returns

- void

Ext.ClassManager
view source
getName( Class/Object object) : String
Get the name of the class by its reference or its instance; usually invoked by the shorthand Ext.getClassName Ext.Cl...

Get the name of the class by its reference or its instance; usually invoked by the shorthand Ext.getClassName

    Ext.ClassManager.getName(Ext.Action); // returns "Ext.Action"

### Parameters

- object : Class/Object

### Returns

- String

  className

Ext.ClassManager
view source
getNameByAlias( String alias) : String

Get the name of a class by its alias.

Get the name of a class by its alias.

### Parameters

- alias : String

### Returns

- String

  className

Ext.ClassManager
view source
getNameByAlternate( String alternate) : String

Get the name of a class by its alternate name.

Get the name of a class by its alternate name.

### Parameters

- alternate : String

### Returns

- String

  className

Ext.ClassManager
view source
getNamesByExpression( String expression) : Array
Converts a string expression to an array of matching class names. An expression can either refers to class aliases or...

Converts a string expression to an array of matching class names. An expression can either refers to class aliases or class names. Expressions support wildcards:

     // returns ['Ext.window.Window']
    var window = Ext.ClassManager.getNamesByExpression('widget.window');

    // returns ['widget.panel', 'widget.window', ...]
    var allWidgets = Ext.ClassManager.getNamesByExpression('widget.*');

    // returns ['Ext.data.Store', 'Ext.data.ArrayProxy', ...]
    var allData = Ext.ClassManager.getNamesByExpression('Ext.data.*');

### Parameters

- expression : String

### Returns

- Array

  classNames

Ext.ClassManager
view source
instantiate( String name, Mixed args) : Object
Instantiate a class by either full name, alias or alternate name; usually invoked by the convenient shorthand Ext.cre...

Instantiate a class by either full name, alias or alternate name; usually invoked by the convenient shorthand Ext.create

If Ext.Loader is enabled and the class has not been defined yet, it will attempt to load the class via synchronous loading.

For example, all these three lines return the same result:

    // alias
    var window = Ext.ClassManager.instantiate('widget.window', { width: 600, height: 800, ... });

    // alternate name
    var window = Ext.ClassManager.instantiate('Ext.Window', { width: 600, height: 800, ... });

    // full class name
    var window = Ext.ClassManager.instantiate('Ext.window.Window', { width: 600, height: 800, ... });

### Parameters

- name : String
- args : Mixed

  ,... Additional arguments after the name will be passed to the class' constructor.

### Returns

- Object

  instance

Ext.ClassManager
view source
instantiateByAlias( String alias, Mixed args) : Object
Instantiate a class by its alias; usually invoked by the convenient shorthand Ext.createByAlias If Ext.Loader is enab...

Instantiate a class by its alias; usually invoked by the convenient shorthand Ext.createByAlias If Ext.Loader is enabled and the class has not been defined yet, it will attempt to load the class via synchronous loading.

    var window = Ext.ClassManager.instantiateByAlias('widget.window', { width: 600, height: 800, ... });

### Parameters

- alias : String
- args : Mixed

  ,... Additional arguments after the alias will be passed to the class constructor.

### Returns

- Object

  instance

Ext.ClassManager
view source
isCreated( String className) : Boolean

Checks if a class has already been created.

Checks if a class has already been created.

### Parameters

- className : String

### Returns

- Boolean

  exist

Ext.ClassManager
view source
registerPostprocessor( String name, Function postprocessor, Object always) : void

Register a post-processor function.

Register a post-processor function.

### Parameters

- name : String
- postprocessor : Function
- always : Object

### Returns

- void

Ext.ClassManager
view source
set( String name, Object value) : Ext.ClassManager

Sets a name reference to a class.

Sets a name reference to a class.

### Parameters

- name : String
- value : Object

### Returns

- Ext.ClassManager

  this

Ext.ClassManager
view source
setAlias( Class/String cls, String alias) : void

Register the alias for a class.

Register the alias for a class.

### Parameters

- cls : Class/String

  a reference to a class or a className

- alias : String

  Alias to use when referring to this class

### Returns

- void

Ext.ClassManager
view source
setDefaultPostprocessorPosition( String name, String offset, String relativeName) : Ext.ClassManager

Insert this post-processor at a specific position in the stack, optionally relative to any existing post-processor

Insert this post-processor at a specific position in the stack, optionally relative to any existing post-processor

### Parameters

- name : String

  The post-processor name. Note that it needs to be registered with registerPostprocessor before this

- offset : String

  The insertion position. Four possible values are: 'first', 'last', or: 'before', 'after' (relative to the name provided in the third argument)

- relativeName : String

### Returns

- Ext.ClassManager

  this

Ext.ClassManager
view source
setDefaultPostprocessors( String/Array The) : Ext.ClassManager

Set the default post processors array stack which are applied to every class.

Set the default post processors array stack which are applied to every class.

### Parameters

- The : String/Array

  name of a registered post processor or an array of registered names.

### Returns

- Ext.ClassManager

  this

Ext.ClassManager
view source
setNamespace( String name, Mixed value) : void
Creates a namespace and assign the value to the created object Ext.ClassManager.setNamespace('MyCompany.pkg.Example'...

Creates a namespace and assign the `value` to the created object

    Ext.ClassManager.setNamespace('MyCompany.pkg.Example', someObject);

    alert(MyCompany.pkg.Example === someObject); // alerts true

### Parameters

- name : String
- value : Mixed

### Returns

- void