Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • BaseDocsMassAction
  • CApplication
  • CApplicationComponent
  • CBehavior
  • CComponent
  • CEnumerable
  • CErrorEvent
  • CErrorHandler
  • CEvent
  • CExceptionEvent
  • CModel
  • CModelBehavior
  • CModelEvent
  • CModule
  • CommonFieldsBehavior
  • CSecurityManager
  • CStatePersister
  • Expression
  • MassAction
  • MassAddToList
  • MassCompleteAction
  • MassMoveFileSysObjToFolder
  • MassRemoveFromList
  • MassRenameFileSysObj
  • MassUncompleteAction
  • MobileRecentItems
  • ModulePanelItem
  • NewListFromSelection
  • PanelItem
  • QuickCRUDBehavior
  • RecentItemPanelItem
  • ServiceRoutingBehavior
  • SettingsPanelItem
  • X2AddressBehavior
  • X2AuthCache
  • X2BaseListViewBehavior

Interfaces

  • IAction
  • IApplicationComponent
  • IAuthManager
  • IBehavior
  • IFilter
  • IStatePersister
  • IUserIdentity
  • IViewRenderer
  • IWebServiceProvider
  • IWebUser

Exceptions

  • CException
  • CHttpException
  • TwitterFeedWidgetException
  • Overview
  • Package
  • Class
  • Tree

Class CModule

CModule is the base class for module and application classes.

CModule mainly manages application components and sub-modules.

CComponent
Extended by CModule

Direct known subclasses

CApplication, CWebModule

Indirect known subclasses

AccountsModule, ActionsModule, MarketingModule, MediaModule, MobileModule, OpportunitiesModule, ProductsModule, QuotesModule, ServicesModule, TemplatesModule, TopicsModule, UsersModule, BugReportsModule, WorkflowModule, X2LeadsModule, X2WebApplication, X2WebModule, CalendarModule, CConsoleApplication, ChartsModule, ContactsModule, CWebApplication, DocsModule, GroupsModule
Abstract
Package: system\base
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Located at x2engine/framework/base/CModule.php
Methods summary
public
# __construct( string $id, CModule $parent, mixed $config = null )

Constructor.

Constructor.

Parameters

$id
string
$id the ID of this module
$parent
CModule
$parent the parent module (if any)
$config
mixed
$config the module configuration. It can be either an array or the path of a PHP file returning the configuration array.
public mixed
# __get( string $name )

Getter magic method. This method is overridden to support accessing application components like reading module properties.

Getter magic method. This method is overridden to support accessing application components like reading module properties.

Parameters

$name
string
$name application component or property name

Returns

mixed
the named property value

Throws

CException
if the property or event is not defined

Overrides

CComponent::__get()
public boolean
# __isset( string $name )

Checks if a property value is null. This method overrides the parent implementation by checking if the named application component is loaded.

Checks if a property value is null. This method overrides the parent implementation by checking if the named application component is loaded.

Parameters

$name
string
$name the property name or the event name

Returns

boolean
whether the property value is null

Overrides

CComponent::__isset()
public string
# getId( )

Returns the module ID.

Returns the module ID.

Returns

string
the module ID.
public
# setId( string $id )

Sets the module ID.

Sets the module ID.

Parameters

$id
string
$id the module ID
public string
# getBasePath( )

Returns the root directory of the module.

Returns the root directory of the module.

Returns

string
the root directory of the module. Defaults to the directory containing the module class.
public
# setBasePath( string $path )

Sets the root directory of the module. This method can only be invoked at the beginning of the constructor.

Sets the root directory of the module. This method can only be invoked at the beginning of the constructor.

Parameters

$path
string
$path the root directory of the module.

Throws

CException
if the directory does not exist.
public CAttributeCollection
# getParams( )

Returns user-defined parameters.

Returns user-defined parameters.

Returns

CAttributeCollection
the list of user-defined parameters
public
# setParams( array $value )

Sets user-defined parameters.

Sets user-defined parameters.

Parameters

$value
array
$value user-defined parameters. This should be in name-value pairs.
public string
# getModulePath( )

Returns the directory that contains the application modules.

Returns the directory that contains the application modules.

Returns

string
the directory that contains the application modules. Defaults to the 'modules' subdirectory of basePath.
public
# setModulePath( string $value )

Sets the directory that contains the application modules.

Sets the directory that contains the application modules.

Parameters

$value
string
$value the directory that contains the application modules.

Throws

CException
if the directory is invalid
public
# setImport( array $aliases )

Sets the aliases that are used in the module.

Sets the aliases that are used in the module.

Parameters

$aliases
array
$aliases list of aliases to be imported
public
# setAliases( array $mappings )

Defines the root aliases.

Defines the root aliases.

Parameters

$mappings
array
$mappings list of aliases to be defined. The array keys are root aliases, while the array values are paths or aliases corresponding to the root aliases. For example, <pre> array( 'models'=>'application.models', // an existing alias 'extensions'=>'application.extensions', // an existing alias 'backend'=>dirname(__FILE__).'/../backend', // a directory ) </pre>
public CModule
# getParentModule( )

Returns the parent module.

Returns the parent module.

Returns

CModule
the parent module. Null if this module does not have a parent.
public CModule
# getModule( string $id )

Retrieves the named application module. The module has to be declared in modules. A new instance will be created when calling this method with the given ID for the first time.

Retrieves the named application module. The module has to be declared in modules. A new instance will be created when calling this method with the given ID for the first time.

Parameters

$id
string
$id application module ID (case-sensitive)

Returns

CModule
the module instance, null if the module is disabled or does not exist.
public boolean
# hasModule( string $id )

Returns a value indicating whether the specified module is installed.

Returns a value indicating whether the specified module is installed.

Parameters

$id
string
$id the module ID

Returns

boolean
whether the specified module is installed.

Since

1.1.2
public array
# getModules( )

Returns the configuration of the currently installed modules.

Returns the configuration of the currently installed modules.

Returns

array
the configuration of the currently installed modules (module ID => configuration)
public
# setModules( array $modules, boolean $merge = true )

Configures the sub-modules of this module.

Configures the sub-modules of this module.

Call this method to declare sub-modules and configure them with their initial property values. The parameter should be an array of module configurations. Each array element represents a single module, which can be either a string representing the module ID or an ID-configuration pair representing a module with the specified ID and the initial property values.

For example, the following array declares two modules:

array(
    'admin',                // a single module ID
    'payment'=>array(       // ID-configuration pair
        'server'=>'paymentserver.com',
    ),
)

By default, the module class is determined using the expression <span class="php-keyword2">ucfirst</span>(<span class="php-var">$moduleID</span>).<span class="php-quote">'Module'</span>. And the class file is located under modules/<span class="php-var">$moduleID</span>. You may override this default by explicitly specifying the 'class' option in the configuration.

You may also enable or disable a module by specifying the 'enabled' option in the configuration.

Parameters

$modules
array
$modules module configurations.
$merge
boolean
$merge whether to merge the new module configuration with the existing one. Defaults to true, meaning the previously registered module configuration with the same ID will be merged with the new configuration. If set to false, the existing configuration will be replaced completely. This parameter is available since 1.1.16.
public boolean
# hasComponent( string $id )

Checks whether the named component exists.

Checks whether the named component exists.

Parameters

$id
string
$id application component ID

Returns

boolean
whether the named application component exists (including both loaded and disabled.)
public IApplicationComponent
# getComponent( string $id, boolean $createIfNull = true )

Retrieves the named application component.

Retrieves the named application component.

Parameters

$id
string
$id application component ID (case-sensitive)
$createIfNull
boolean
$createIfNull whether to create the component if it doesn't exist yet.

Returns

IApplicationComponent
the application component instance, null if the application component is disabled or does not exist.

See

CModule::hasComponent()
public
# setComponent( string $id, array|IApplicationComponent $component, boolean $merge = true )

Puts a component under the management of the module. The component will be initialized by calling its CApplicationComponent::init() init() method if it has not done so.

Puts a component under the management of the module. The component will be initialized by calling its CApplicationComponent::init() init() method if it has not done so.

Parameters

$id
string
$id component ID
$component
array|IApplicationComponent
$component application component (either configuration array or instance). If this parameter is null, component will be unloaded from the module.
$merge
boolean
$merge whether to merge the new component configuration with the existing one. Defaults to true, meaning the previously registered component configuration with the same ID will be merged with the new configuration. If set to false, the existing configuration will be replaced completely. This parameter is available since 1.1.13.
public array
# getComponents( boolean $loadedOnly = true )

Returns the application components.

Returns the application components.

Parameters

$loadedOnly
boolean
$loadedOnly whether to return the loaded components only. If this is set false, then all components specified in the configuration will be returned, whether they are loaded or not. Loaded components will be returned as objects, while unloaded components as configuration arrays. This parameter has been available since version 1.1.3.

Returns

array
the application components (indexed by their IDs)
public
# setComponents( array $components, boolean $merge = true )

Sets the application components.

Sets the application components.

When a configuration is used to specify a component, it should consist of the component's initial property values (name-value pairs). Additionally, a component can be enabled (default) or disabled by specifying the 'enabled' value in the configuration.

If a configuration is specified with an ID that is the same as an existing component or configuration, the existing one will be replaced silently.

The following is the configuration for two components:

array(
    'db'=>array(
        'class'=>'CDbConnection',
        'connectionString'=>'sqlite:path/to/file.db',
    ),
    'cache'=>array(
        'class'=>'CDbCache',
        'connectionID'=>'db',
        'enabled'=>!YII_DEBUG,  // enable caching in non-debug mode
    ),
)

Parameters

$components
array
$components application components(id=>component configuration or instances)
$merge
boolean
$merge whether to merge the new component configuration with the existing one. Defaults to true, meaning the previously registered component configuration of the same ID will be merged with the new configuration. If false, the existing configuration will be replaced completely.
public
# configure( array $config )

Configures the module with the specified configuration.

Configures the module with the specified configuration.

Parameters

$config
array
$config the configuration array
protected
# preloadComponents( )

Loads static application components.

Loads static application components.

protected
# preinit( )

Preinitializes the module. This method is called at the beginning of the module constructor. You may override this method to do some customized preinitialization work. Note that at this moment, the module is not configured yet.

Preinitializes the module. This method is called at the beginning of the module constructor. You may override this method to do some customized preinitialization work. Note that at this moment, the module is not configured yet.

See

CModule::init()
protected
# init( )

Initializes the module. This method is called at the end of the module constructor. Note that at this moment, the module has been configured, the behaviors have been attached and the application components have been registered.

Initializes the module. This method is called at the end of the module constructor. Note that at this moment, the module has been configured, the behaviors have been attached and the application components have been registered.

See

CModule::preinit()
Methods inherited from CComponent
__call(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public array $preload array()
#

the IDs of the application components that should be preloaded.

the IDs of the application components that should be preloaded.

public array $behaviors array()
#

the behaviors that should be attached to the module. The behaviors will be attached to the module when CModule::init() is called. Please refer to CModel::behaviors() on how to specify the value of this property.

the behaviors that should be attached to the module. The behaviors will be attached to the module when CModule::init() is called. Please refer to CModel::behaviors() on how to specify the value of this property.

Magic properties summary
public string $id
#

The module ID.

The module ID.

public string $basePath
#

The root directory of the module. Defaults to the directory containing the module class.

The root directory of the module. Defaults to the directory containing the module class.

public CAttributeCollection $params
#

The list of user-defined parameters.

The list of user-defined parameters.

public string $modulePath
#

The directory that contains the application modules. Defaults to the 'modules' subdirectory of basePath.

The directory that contains the application modules. Defaults to the 'modules' subdirectory of basePath.

public CModule $parentModule
#

The parent module. Null if this module does not have a parent.

The parent module. Null if this module does not have a parent.

public array $modules
#

The configuration of the currently installed modules (module ID => configuration).

The configuration of the currently installed modules (module ID => configuration).

public array $components
#

The application components (indexed by their IDs).

The application components (indexed by their IDs).

public array $import
#

List of aliases to be imported.

List of aliases to be imported.

public array $aliases
#

List of aliases to be defined. The array keys are root aliases, while the array values are paths or aliases corresponding to the root aliases. For example,

 array(    'models'=>'application.models',              // an existing alias    'extensions'=>'application.extensions',      // an existing alias    'backend'=>dirname(__FILE__).'/../backend',  // a directory ) 

List of aliases to be defined. The array keys are root aliases, while the array values are paths or aliases corresponding to the root aliases. For example,

 array(    'models'=>'application.models',              // an existing alias    'extensions'=>'application.extensions',      // an existing alias    'backend'=>dirname(__FILE__).'/../backend',  // a directory ) 
API documentation generated by ApiGen 2.8.0