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 CComponent

CComponent is the base class for all components.

CComponent implements the protocol of defining, using properties and events.

A property is defined by a getter method, and/or a setter method. Properties can be accessed in the way like accessing normal object members. Reading or writing a property will cause the invocation of the corresponding getter or setter method, e.g

$a=$component->text;     // equivalent to $a=$component->getText();
$component->text='abc';  // equivalent to $component->setText('abc');

The signatures of getter and setter methods are as follows,

// getter, defines a readable property 'text'
public function getText() { ... }
// setter, defines a writable property 'text' with $value to be set to the property
public function setText($value) { ... }

An event is defined by the presence of a method whose name starts with 'on'. The event name is the method name. When an event is raised, functions (called event handlers) attached to the event will be invoked automatically.

An event can be raised by calling CComponent::raiseEvent() method, upon which the attached event handlers will be invoked automatically in the order they are attached to the event. Event handlers must have the following signature,

function eventHandler($event) { ... }

where $event includes parameters associated with the event.

To attach an event handler to an event, see CComponent::attachEventHandler(). You can also use the following syntax:

$component->onClick=$callback;    // or $component->onClick->add($callback);

where $callback refers to a valid PHP callback. Below we show some callback examples:

'handleOnClick'                   // handleOnClick() is a global function
array($object,'handleOnClick')    // using $object->handleOnClick()
array('Page','handleOnClick')     // using Page::handleOnClick()

To raise an event, use CComponent::raiseEvent(). The on-method defining an event is commonly written like the following:

public function onClick($event)
{
    $this->raiseEvent('onClick',$event);
}

where <span class="php-var">$event</span> is an instance of CEvent or its child class. One can then raise the event by calling the on-method instead of CComponent::raiseEvent() directly.

Both property names and event names are case-insensitive.

CComponent supports behaviors. A behavior is an instance of IBehavior which is attached to a component. The methods of the behavior can be invoked as if they belong to the component. Multiple behaviors can be attached to the same component.

To attach a behavior to a component, call CComponent::attachBehavior(); and to detach the behavior from the component, call CComponent::detachBehavior().

A behavior can be temporarily enabled or disabled by calling CComponent::enableBehavior() or CComponent::disableBehavior(), respectively. When disabled, the behavior methods cannot be invoked via the component.

Starting from version 1.1.0, a behavior's properties (either its public member variables or its properties defined via getters and/or setters) can be accessed through the component it is attached to.

Direct known subclasses

CAccessRule, CAction, CBehavior, CCacheDependency, CChainedCacheDependency, CChainedLogFilter, CConsoleCommand, CConsoleCommandRunner, CDataProvider, CDataProviderIterator, CDateFormatter, CDbColumnSchema, CActiveFinder, CDbCommand, CDbCommandBuilder, CDbCriteria, CDbDataReader, CDbExpression, CDbMigration, CDbSchema, CDbTableSchema, CDbTransaction, CEvent, CApplicationComponent, CFilter, CFormElement, CGettextFile, CGridColumn, CHttpCookie, CList, CLocale, CLogFilter, CLogger, CLogRoute, CAuthAssignment, CMap, CMemCacheServerConfiguration, CModel, CModule, CNumberFormatter, CPagination, CQueue, CSort, CStack, CTheme, CAuthItem, CUploadedFile, CValidator, CWebService, CWsdlGenerator, Expression, FieldFormatterBase, FieldInputRenderer, JSONResponse, MassAction, MobileRecentItems, CBaseActiveRelation, PanelItem, QueryParamGenerator, RequestUtil, TranslationLogger, X2FlowItem, X2StaticDropdown, X2StaticField, CBaseController, CBaseUrlRule, CBaseUserIdentity

Indirect known subclasses

Accounts, AccountsController, ActionMetaData, CDbConnection, CDbFixtureManager, CDbHttpSession, CDbLogRoute, CDbMessageSource, CDefaultValueValidator, CDetailView, CDirectoryCacheDependency, CDummyCache, CEAcceleratorCache, ActionOverdueTrigger, CEmailLogRoute, CEmailValidator, CErrorEvent, CErrorHandler, CExceptionEvent, CExistValidator, CExpressionDependency, CExtController, CFileCache, CFileCacheDependency, Actions, CFileLogRoute, CFileValidator, CFilterChain, CFilterValidator, CFilterWidget, CFlexWidget, CForm, CFormatter, CFormButtonElement, CFormElementCollection, ActionsController, CFormInputElement, CFormModel, CFormStringElement, CGettextMessageSource, CGettextMoFile, CGettextPoFile, CGlobalStateCacheDependency, CGridView, Changelog, ChartSetting, ActionsGridViewProfileWidget, ChartsModule, ChartWidget, CHasManyRelation, CHasOneRelation, ChatBox, CHelpCommand, CHtmlPurifier, CHttpCacheFilter, CHttpRequest, CHttpSession, ActionsModule, CInlineAction, CInlineFilter, CInlineValidator, CInputWidget, CJuiAccordion, CJuiAutoComplete, CJuiButton, CJuiDatePicker, CJuiDialog, CJuiDraggable, ActionsQuickCreateRelationshipBehavior, CJuiDroppable, CJuiInputWidget, CJuiProgressBar, CJuiResizable, CJuiSelectable, CJuiSlider, CJuiSliderInput, CJuiSortable, CJuiTabs, CJuiWidget, ActionsWidget, CLinkColumn, CLinkPager, CListPager, CListView, CLocalizedFormatter, CLogRouter, CManyManyRelation, CMarkdown, CMaskedTextField, CMemCache, ActionText, CMenu, CMessageSource, CMissingTranslationEvent, CModelBehavior, CModelEvent, CMssqlColumnSchema, CMssqlCommandBuilder, CMssqlSchema, CMssqlTableSchema, CMultiFileUpload, ActionToRecord, CMysqlColumnSchema, CMysqlCommandBuilder, CMysqlSchema, CMysqlTableSchema, CNumberValidator, COciColumnSchema, COciCommandBuilder, COciSchema, COciTableSchema, CommentsWidget, AccountsGridViewProfileWidget, ActionUncompleteTrigger, CommonControllerBehavior, CommonFieldsBehavior, CommonSiteControllerBehavior, ContactForm, ContactList, ContactMapInlineTags, Contacts, ContactsController, ContactsGridViewProfileWidget, ContactsModule, ActiveDateRangeInput, ContactsNameBehavior, ControllerPermissionsBehavior, COutputCache, COutputEvent, COutputProcessor, CPgsqlColumnSchema, CPgsqlCommandBuilder, CPgsqlSchema, CPgsqlTableSchema, CPhpAuthManager, Admin, CPhpMessageSource, CPortlet, CPradoViewRenderer, CProfileLogRoute, CRangeValidator, CreatePageFormModel, CreateWebFormAction, Credentials, CRedisCache, CRegularExpressionValidator, AdminController, CRequiredValidator, Criteria, CronCommand, CronForm, CryptSetupCommand, CSafeValidator, CSaveRelationsBehavior, CSecurityManager, CSqlDataProvider, CSqliteColumnSchema, AjaxGetModelAutocompleteAction, CSqliteCommandBuilder, CSqliteSchema, CStarRating, CStatePersister, CStatRelation, CStringValidator, CSysLogRoute, CTabView, CTextHighlighter, CThemeManager, AmorphousModel, CTimestampBehavior, CTreeView, CTypedList, CTypedMap, CTypeValidator, CUniqueValidator, CUnsafeValidator, CUrlManager, CUrlRule, CUrlValidator, Api2Controller, CUserIdentity, CViewAction, CViewRenderer, CWebApplication, CWebLogRoute, CWebModule, CWebServiceAction, CWebUser, CWidget, CWidgetFactory, ApiController, CWinCache, CXCache, CZendDataCache, DatabaseBackupAction, DateRangeInputsWidget, DetailView, DocFolders, Docs, DocsController, DocsGridViewProfileWidget, ApiHook, DocsModule, DocViewer, DocViewerProfileWidget, Dropdowns, DummyCommand, EButtonColumnWithClearFilters, EditMobileFormsFormModel, EmailAccount, EmailDeliveryBehavior, EmailDropboxSettings, ApplicationConfigBehavior, EmailOpenTrigger, EmailProgressControl, EmailsWidget, EncryptedFieldsBehavior, ERememberFiltersBehavior, EventActiveForm, EventCommentPublisherFormModel, EventFormModel, EventPublisherFormModel, Events, AccountsModule, ArrayValidator, EventsChartProfileWidget, EventsData, EventsWidget, EventsWidgetFieldFormatter, ExportFixtureCommand, FailedLogins, FieldFormatter, Fields, FileFieldBehavior, FileSystemObjectBehavior, AssociatedMediaBehavior, FileSystemObjectDataProvider, FileUploader, FileUploadsFilter, FiltersForm, FontPickerInput, FormLayout, FormView, GetActionsBetweenAction, GetItemsAction, GlobalCSSFormModel, Attachments, GlobalImportFormModel, GMailAccount, GoogleProject, GridViewDbSettingsBehavior, GridViewSessionSettingsBehavior, GridViewWidget, Groups, GroupsController, GroupsModule, GroupToUser, AutomaticTranslationCommand, History, IframeWidget, ImportExportBehavior, Imports, InboundEmailTrigger, InlineActionForm, InlineEmail, InlineEmailAction, InlineEmailForm, InlineEmailModelBehavior, BaseDocsMassAction, InlineQuotes, InlineRelationshipsGridView, InlineRelationshipsWidget, InlineTagsWidget, JSONEmbeddedModel, JSONEmbeddedModelFieldsBehavior, JSONFieldsBehavior, JSONFieldsDefaultValuesBehavior, LeadRouting, LeadRoutingBehavior, BaseTagTrigger, LeftWidget, Locations, LoggedTimeWidget, LoginForm, MacroTrigger, MailgunAccount, MailjetAccount, MandrillAccount, Maps, MarketingController, BaseUserTrigger, MarketingGridViewProfileWidget, MarketingModule, MassActionFormModel, MassAddToList, MassCompleteAction, MassMoveFileSysObjToFolder, MassRemoveFromList, MassRenameFileSysObj, MassUncompleteAction, Media, BaseWorkflowStageTrigger, MediaBox, MediaController, MediaFieldFormatter, MediaModule, MediaSelector, MenuList, MessageBox, MigrateCustomCommand, MobileAction, MobileActiveForm, BaseWorkflowTrigger, MobileActiveRecordFieldFormatter, MobileActivityAction, MobileActivityFeedListView, MobileCaptcha, MobileController, MobileCreateAction, MobileDeleteAction, MobileFieldFormatter, MobileFieldInputRenderer, MobileFormLayoutRenderer, BaseX2FlowEmail, MobileIndexAction, MobileLayoutRenderer, MobileLayouts, MobileModule, MobilePagination, MobileProfileViewAction, MobilePublisherAction, MobileRecordIndexPager, MobileResetPasswordAction, MobileTopicsCreateAction, ActionActiveForm, BaseX2FlowWorkflowStageAction, MobileTopicsDeleteReplyAction, MobileTopicsIndexAction, MobileTopicsPager, MobileTopicsUpdateAction, MobileTopicsUpdateReplyAction, MobileTopicsViewAction, MobileUpdateAction, MobileViewAction, MobileViewEventAction, MobileViewLayoutRenderer, BugReports, ModelFileUploader, ModelPermissionsBehavior, ModuleModelNameValidator, ModulePanelItem, Modules, MultiChildNode, MultiTypeAutocomplete, NewListFromSelection, NewWebLeadsGridViewProfileWidget, NormalizedJSONFieldsBehavior, BugReportsController, NoteActiveForm, NoteBox, NoteFormModel, Notes, Notification, NotificationsController, OnlineUsers, OpportunitiesController, OpportunitiesGridViewProfileWidget, OpportunitiesModule, BugReportsModule, Opportunity, OutboundEmailTrigger, OutlookEmailAccount, Panel, PasswordReset, PasswordResetForm, PhoneNumber, Product, ProductFeature, ProductsController, CAccessControlFilter, ProductsModule, Profile, ProfileController, ProfileDashboardManager, ProfileGridViewWidget, ProfileInfo, ProfileLayoutEditor, ProfilesGridViewProfileWidget, ProfileWidgetLayout, Publisher, CActiveDataProvider, PublisherActionTab, PublisherCalendarEventTab, PublisherCallTab, PublisherCommentTab, PublisherEventTab, PublisherSmallCalendarEventTab, PublisherTab, PublisherTimeTab, PublisherWidget, QuickContact, CActiveForm, QuickCreateRelationshipBehavior, QuickCRUDBehavior, Quote, QuoteProduct, QuotesController, QuotesGridViewProfileWidget, QuotesModule, QuotesWidget, RecentItemPanelItem, RecentItems, CActiveRecord, RecordAliases, RecordAliasesCreateAction, RecordAliasesDeleteAction, RecordAliasesWidget, RecordCreateTrigger, RecordDeleteTrigger, RecordIndexListView, RecordLimitBehavior, RecordTagAddTrigger, RecordTagRemoveTrigger, CActiveRecordBehavior, RecordUpdateTrigger, RecordView, RecordViewLayoutManager, RecordViewTrigger, RecordViewWidgetLayout, RecordViewWidgetManager, Relationships, RelationshipsBehavior, RelationshipsController, RelationshipsGridModel, CActiveRelation, RelationshipsJoin, RememberPagination, Reminders, RepairUserDataCommand, RequiredIfNotSetValidator, ResponseBehavior, Roles, RoleToPermission, RoleToUser, RoleToWorkflow, ActionActiveFormBase, CalendarController, RunMigrationScriptCommand, SampleDataCommand, SearchController, SearchIndexBehavior, SendgridAccount, ServiceRoutingBehavior, Services, ServicesController, ServicesGridViewProfileWidget, ServicesModule, CalendarEvent, ServiceWebFormDesigner, SESAccount, Session, SessionLog, Settings, SettingsPanelItem, SiteController, SmallCalendar, SmartActiveDataProvider, SmartDataProviderBehavior, CalendarEventActiveForm, SmartSort, Social, SocialForm, SortableWidget, SortableWidgetManager, SortableWidgets, StudioController, TagBehavior, TagCloud, Tags, CalendarEventFormModel, TempFile, Templates, TemplatesController, TemplatesGridViewProfileWidget, TemplatesModule, TestEmailAction, TestEmailActionForm, ThemeBuildCommand, TimeActiveForm, TimeFormModel, CalendarModule, TimeZone, Tips, TopContacts, TopicReplies, Topics, TopicsController, TopicsFieldFormatter, TopicsListView, TopicsModule, TopicsWidgetLayout, CallActiveForm, TopSites, Tours, TrackEmail, TransactionalViewFieldFormatter, TransactionalViewWidget, TransformedFieldStorageBehavior, TriggerLog, TwitterApp, TwitterFeed, TwitterFeedWidget, CallFormModel, TwoColumnSortableWidgetManager, UpdateCommand, UpdaterAction, UpdaterBehavior, UpdaterPackageCommand, UpdateStageAction, UploadLogoFormModel, URL, User, UserIdentity, CallsWidget, UserLoginTrigger, UserLogoutTrigger, UsersChartProfileWidget, UsersController, UsersModule, ValidLinkValidator, ViewLog, WebActivityWidget, WebForm, WebFormAction, Campaign, WebFormDesigner, WebLeadFormDesigner, WebleadTrigger, WebUpdaterAction, WidgetLayout, Widgets, Workflow, WorkflowBehavior, WorkflowCompleteStageTrigger, WorkflowCompleteTrigger, CampaignAttachment, WorkflowController, WorkflowModule, WorkflowRevertStageTrigger, WorkflowStage, WorkflowStageDetailsWidget, WorkflowStartStageTrigger, WorkflowStartTrigger, X2ActiveForm, X2ActiveGridView, X2ActiveGridViewForSortableWidgets, ActionCompleteTrigger, CampaignEmailClickTrigger, X2ActiveRecord, X2ActiveRecordBehavior, X2ActiveRecordFieldFormatter, X2AddressBehavior, X2AjaxHandlerFilter, X2AssetManager, X2AuthCache, X2AuthManager, x2base, X2BaseListViewBehavior, CampaignEmailOpenTrigger, X2ButtonColumn, X2CalendarPermissions, X2ChangeLogBehavior, X2CheckBoxColumn, X2ConditionList, X2ConsoleCommand, X2Controller, X2ControllerBehavior, X2ControllerPermissionsBehavior, X2DataColumn, CampaignMailingBehavior, X2DataColumnGeneric, X2DbCriteria, X2DuplicateBehavior, X2FileCache, X2FixtureManager, X2Flow, X2FlowAction, X2FlowApiCall, X2FlowCreateAction, X2FlowCreateEvent, CampaignUnsubscribeTrigger, X2FlowCreateNotif, X2FlowEmail, X2FlowRecordComment, X2FlowRecordCreate, X2FlowRecordCreateAction, X2FlowRecordDelete, X2FlowRecordListAdd, X2FlowRecordListRemove, X2FlowRecordReassign, X2FlowRecordTag, CApcCache, X2FlowRecordUpdate, X2FlowSplitter, X2FlowSwitch, X2FlowTrigger, X2FlowTriggerBehavior, X2FlowWorkflowCompleteStage, X2FlowWorkflowRevertStage, X2FlowWorkflowStartStage, X2FormModel, X2GridView, CApplication, X2GridViewBase, X2GridViewFieldFormatter, X2GridViewForSortableWidgets, X2GridViewGeneric, X2GridViewMassActionAction, X2GridViewSortableWidgetsBehavior, X2HttpRequest, X2Leads, X2LeadsController, X2LeadsDataColumn, CArrayDataProvider, X2LeadsGridViewProfileWidget, X2LeadsModule, X2LinkableBehavior, X2List, X2ListCriterion, X2ListItem, X2ListView, X2MarketingChartModel, X2MergeableBehavior, X2MessageSource, CAssetManager, X2MobileControllerBehavior, X2MobileProfileControllerBehavior, X2MobileQuotesControllerBehavior, X2MobileSiteControllerBehavior, X2MobileTopicsControllerBehavior, X2Model, X2ModelConversionAction, X2ModelConversionBehavior, X2ModelConversionWidget, X2ModelForeignKeyValidator, CAttributeCollection, X2ModelUniqueIndexValidator, X2NonWebUser, X2PermissionsBehavior, X2PillBox, X2PipelineChartModel, X2ProgressBar, X2SalesChartModel, X2Settings, X2SmartSearchModelBehavior, X2StarRating, CAuthManager, X2StaticFieldsBehavior, X2TimestampBehavior, X2TranslationBehavior, X2UrlManager, X2UrlRule, X2UrlValidator, X2Validator, X2WebApplication, X2WebModule, X2WebUser, ActionFormModel, CBaseListView, X2Widget, X2WidgetBehavior, X2WidgetList, YahooEmailAccount, CBasePager, CBelongsToRelation, CBooleanValidator, CBreadcrumbs, CButtonColumn, CCache, CCacheHttpSession, CCaptcha, CCaptchaAction, ActionFormModelBase, CCaptchaValidator, CCheckBoxColumn, CClientScript, CClipWidget, CCompareValidator, CConfiguration, CConsoleApplication, CConsoleCommandBehavior, CConsoleCommandEvent, CContentDecorator, ActionMenu, CController, CCookieCollection, CCubridColumnSchema, CCubridSchema, CCubridTableSchema, CDataColumn, CDateValidator, CDbAuthManager, CDbCache, CDbCacheDependency
Package: system\base
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/base/CComponent.php
Methods summary
public mixed
# __get( string $name )

Returns a property value, an event handler list or a behavior based on its name. Do not call this method. This is a PHP magic method that we override to allow using the following syntax to read a property or obtain event handlers:

$value=$component->propertyName;
$handlers=$component->eventName;

Returns a property value, an event handler list or a behavior based on its name. Do not call this method. This is a PHP magic method that we override to allow using the following syntax to read a property or obtain event handlers:

$value=$component->propertyName;
$handlers=$component->eventName;

Parameters

$name
string
$name the property name or event name

Returns

mixed
the property value, event handlers attached to the event, or the named behavior

Throws

CException
if the property or event is not defined

See

CComponent::__set()
public mixed
# __set( string $name, mixed $value )

Sets value of a component property. Do not call this method. This is a PHP magic method that we override to allow using the following syntax to set a property or attach an event handler

$this->propertyName=$value;
$this->eventName=$callback;

Sets value of a component property. Do not call this method. This is a PHP magic method that we override to allow using the following syntax to set a property or attach an event handler

$this->propertyName=$value;
$this->eventName=$callback;

Parameters

$name
string
$name the property name or the event name
$value
mixed
$value the property value or callback

Returns

mixed

Throws

CException
if the property/event is not defined or the property is read only.

See

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

Checks if a property value is null. Do not call this method. This is a PHP magic method that we override to allow using isset() to detect if a component property is set or not.

Checks if a property value is null. Do not call this method. This is a PHP magic method that we override to allow using isset() to detect if a component property is set or not.

Parameters

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

Returns

boolean
public mixed
# __unset( string $name )

Sets a component property to be null. Do not call this method. This is a PHP magic method that we override to allow using unset() to set a component property to be null.

Sets a component property to be null. Do not call this method. This is a PHP magic method that we override to allow using unset() to set a component property to be null.

Parameters

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

Returns

mixed

Throws

CException
if the property is read only.
public mixed
# __call( string $name, array $parameters )

Calls the named method which is not a class method. Do not call this method. This is a PHP magic method that we override to implement the behavior feature.

Calls the named method which is not a class method. Do not call this method. This is a PHP magic method that we override to implement the behavior feature.

Parameters

$name
string
$name the method name
$parameters
array
$parameters method parameters

Returns

mixed
the method return value

Throws

CException
if current class and its behaviors do not have a method or closure with the given name
public IBehavior
# asa( string $behavior )

Returns the named behavior object. The name 'asa' stands for 'as a'.

Returns the named behavior object. The name 'asa' stands for 'as a'.

Parameters

$behavior
string
$behavior the behavior name

Returns

IBehavior
the behavior object, or null if the behavior does not exist
public
# attachBehaviors( array $behaviors )

Attaches a list of behaviors to the component. Each behavior is indexed by its name and should be an instance of IBehavior, a string specifying the behavior class, or an array of the following structure:

array(
    'class'=>'path.to.BehaviorClass',
    'property1'=>'value1',
    'property2'=>'value2',
)

Attaches a list of behaviors to the component. Each behavior is indexed by its name and should be an instance of IBehavior, a string specifying the behavior class, or an array of the following structure:

array(
    'class'=>'path.to.BehaviorClass',
    'property1'=>'value1',
    'property2'=>'value2',
)

Parameters

$behaviors
array
$behaviors list of behaviors to be attached to the component
public
# detachBehaviors( )

Detaches all behaviors from the component.

Detaches all behaviors from the component.

public IBehavior
# attachBehavior( string $name, mixed $behavior )

Attaches a behavior to this component. This method will create the behavior object based on the given configuration. After that, the behavior object will be initialized by calling its IBehavior::attach() method.

Attaches a behavior to this component. This method will create the behavior object based on the given configuration. After that, the behavior object will be initialized by calling its IBehavior::attach() method.

Parameters

$name
string
$name the behavior's name. It should uniquely identify this behavior.
$behavior
mixed
$behavior the behavior configuration. This is passed as the first parameter to YiiBase::createComponent() to create the behavior object. You can also pass an already created behavior instance (the new behavior will replace an already created behavior with the same name, if it exists).

Returns

IBehavior
the behavior object
public IBehavior
# detachBehavior( string $name )

Detaches a behavior from the component. The behavior's IBehavior::detach() method will be invoked.

Detaches a behavior from the component. The behavior's IBehavior::detach() method will be invoked.

Parameters

$name
string
$name the behavior's name. It uniquely identifies the behavior.

Returns

IBehavior
the detached behavior. Null if the behavior does not exist.
public
# enableBehaviors( )

Enables all behaviors attached to this component.

Enables all behaviors attached to this component.

public
# disableBehaviors( )

Disables all behaviors attached to this component.

Disables all behaviors attached to this component.

public
# enableBehavior( string $name )

Enables an attached behavior. A behavior is only effective when it is enabled. A behavior is enabled when first attached.

Enables an attached behavior. A behavior is only effective when it is enabled. A behavior is enabled when first attached.

Parameters

$name
string
$name the behavior's name. It uniquely identifies the behavior.
public
# disableBehavior( string $name )

Disables an attached behavior. A behavior is only effective when it is enabled.

Disables an attached behavior. A behavior is only effective when it is enabled.

Parameters

$name
string
$name the behavior's name. It uniquely identifies the behavior.
public boolean
# hasProperty( string $name )

Determines whether a property is defined. A property is defined if there is a getter or setter method defined in the class. Note, property names are case-insensitive.

Determines whether a property is defined. A property is defined if there is a getter or setter method defined in the class. Note, property names are case-insensitive.

Parameters

$name
string
$name the property name

Returns

boolean
whether the property is defined

See

CComponent::canGetProperty()
CComponent::canSetProperty()
public boolean
# canGetProperty( string $name )

Determines whether a property can be read. A property can be read if the class has a getter method for the property name. Note, property name is case-insensitive.

Determines whether a property can be read. A property can be read if the class has a getter method for the property name. Note, property name is case-insensitive.

Parameters

$name
string
$name the property name

Returns

boolean
whether the property can be read

See

CComponent::canSetProperty()
public boolean
# canSetProperty( string $name )

Determines whether a property can be set. A property can be written if the class has a setter method for the property name. Note, property name is case-insensitive.

Determines whether a property can be set. A property can be written if the class has a setter method for the property name. Note, property name is case-insensitive.

Parameters

$name
string
$name the property name

Returns

boolean
whether the property can be written

See

CComponent::canGetProperty()
public boolean
# hasEvent( string $name )

Determines whether an event is defined. An event is defined if the class has a method named like 'onXXX'. Note, event name is case-insensitive.

Determines whether an event is defined. An event is defined if the class has a method named like 'onXXX'. Note, event name is case-insensitive.

Parameters

$name
string
$name the event name

Returns

boolean
whether an event is defined
public boolean
# hasEventHandler( string $name )

Checks whether the named event has attached handlers.

Checks whether the named event has attached handlers.

Parameters

$name
string
$name the event name

Returns

boolean
whether an event has been attached one or several handlers
public CList
# getEventHandlers( string $name )

Returns the list of attached event handlers for an event.

Returns the list of attached event handlers for an event.

Parameters

$name
string
$name the event name

Returns

CList
list of attached event handlers for the event

Throws

CException
if the event is not defined
public
# attachEventHandler( string $name, callable $handler )

Attaches an event handler to an event.

Attaches an event handler to an event.

An event handler must be a valid PHP callback, i.e., a string referring to a global function name, or an array containing two elements with the first element being an object and the second element a method name of the object.

An event handler must be defined with the following signature,

function handlerName($event) {}

where $event includes parameters associated with the event.

This is a convenient method of attaching a handler to an event. It is equivalent to the following code:

$component->getEventHandlers($eventName)->add($eventHandler);

Using CComponent::getEventHandlers(), one can also specify the execution order of multiple handlers attaching to the same event. For example:

$component->getEventHandlers($eventName)->insertAt(0,$eventHandler);

makes the handler to be invoked first.

Parameters

$name
string
$name the event name
$handler
callable
$handler the event handler

Throws

CException
if the event is not defined

See

CComponent::detachEventHandler()
public boolean
# detachEventHandler( string $name, callable $handler )

Detaches an existing event handler. This method is the opposite of CComponent::attachEventHandler().

Detaches an existing event handler. This method is the opposite of CComponent::attachEventHandler().

Parameters

$name
string
$name event name
$handler
callable
$handler the event handler to be removed

Returns

boolean
if the detachment process is successful

See

CComponent::attachEventHandler()
public
# raiseEvent( string $name, CEvent $event )

Raises an event. This method represents the happening of an event. It invokes all attached handlers for the event.

Raises an event. This method represents the happening of an event. It invokes all attached handlers for the event.

Parameters

$name
string
$name the event name
$event
CEvent
$event the event parameter

Throws

CException
if the event is undefined or an event handler is invalid.
public mixed
# evaluateExpression( mixed $_expression_, array $_data_ = array() )

Evaluates a PHP expression or callback under the context of this component.

Evaluates a PHP expression or callback under the context of this component.

Valid PHP callback can be class method name in the form of array(ClassName/Object, MethodName), or anonymous function (only available in PHP 5.3.0 or above).

If a PHP callback is used, the corresponding function/method signature should be

function foo($param1, $param2, ..., $component) { ... }

where the array elements in the second parameter to this method will be passed to the callback as $param1, $param2, ...; and the last parameter will be the component itself.

If a PHP expression is used, the second parameter will be "extracted" into PHP variables that can be directly accessed in the expression. See PHP extract for more details. In the expression, the component object can be accessed using $this.

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

Parameters

$_expression_
mixed
$_expression_ a PHP expression or PHP callback to be evaluated.
$_data_
array
$_data_ additional parameters to be passed to the above expression/callback.

Returns

mixed
the expression result

Since

1.1.0
API documentation generated by ApiGen 2.8.0