PHP 클래스 yii\base\Component

상속: extends Object
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 메소드들

메소드 설명
__call ( string $name, array $params ) : mixed Calls the named method which is not a class method.
__clone ( ) This method is called after the object is created by cloning an existing one.
__get ( string $name ) : mixed Returns the value of a component property.
__isset ( string $name ) : boolean Checks if a property is set, i.e. defined and not null.
__set ( string $name, mixed $value ) Sets the value of a component property.
__unset ( string $name ) Sets a component property to be null.
attachBehavior ( string $name, string | array | Behavior $behavior ) : Behavior Attaches a behavior to this component.
attachBehaviors ( array $behaviors ) Attaches a list of behaviors to the component.
behaviors ( ) : array Returns a list of behaviors that this component should behave as.
canGetProperty ( string $name, boolean $checkVars = true, boolean $checkBehaviors = true ) : boolean Returns a value indicating whether a property can be read.
canSetProperty ( string $name, boolean $checkVars = true, boolean $checkBehaviors = true ) : boolean Returns a value indicating whether a property can be set.
detachBehavior ( string $name ) : null | Behavior Detaches a behavior from the component.
detachBehaviors ( ) Detaches all behaviors from the component.
ensureBehaviors ( ) Makes sure that the behaviors declared in Component::behaviors are attached to this component.
getBehavior ( string $name ) : null | Behavior Returns the named behavior object.
getBehaviors ( ) : Behavior[] Returns all behaviors attached to this component.
hasEventHandlers ( string $name ) : boolean Returns a value indicating whether there is any handler attached to the named event.
hasMethod ( string $name, boolean $checkBehaviors = true ) : boolean Returns a value indicating whether a method is defined.
hasProperty ( string $name, boolean $checkVars = true, boolean $checkBehaviors = true ) : boolean Returns a value indicating whether a property is defined for this component.
off ( string $name, callable $handler = null ) : boolean Detaches an existing event handler from this component.
on ( string $name, callable $handler, mixed $data = null, boolean $append = true ) Attaches an event handler to an event.
trigger ( string $name, Event $event = null ) Triggers an event.

비공개 메소드들

메소드 설명
attachBehaviorInternal ( string | integer $name, string | array | Behavior $behavior ) : Behavior Attaches a behavior to this component.

메소드 상세

__call() 공개 메소드

This method will check if any attached behavior has the named method and will execute it if available. Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
public __call ( string $name, array $params ) : mixed
$name string the method name
$params array method parameters
리턴 mixed the method return value

__clone() 공개 메소드

It removes all behaviors because they are attached to the old object.
public __clone ( )

__get() 공개 메소드

This method will check in the following order and act accordingly: - a property defined by a getter: return the getter result - a property of a behavior: return the behavior property value Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $value = $component->property;.
또한 보기: __set()
public __get ( string $name ) : mixed
$name string the property name
리턴 mixed the property value or the value of a behavior's property

__isset() 공개 메소드

This method will check in the following order and act accordingly: - a property defined by a setter: return whether the property is set - a property of a behavior: return whether the property is set - return false for non existing properties Do not call this method directly as it is a PHP magic method that will be implicitly called when executing isset($component->property).
또한 보기: http://php.net/manual/en/function.isset.php
public __isset ( string $name ) : boolean
$name string the property name or the event name
리턴 boolean whether the named property is set

__set() 공개 메소드

This method will check in the following order and act accordingly: - a property defined by a setter: set the property value - an event in the format of "on xyz": attach the handler to the event "xyz" - a behavior in the format of "as xyz": attach the behavior named as "xyz" - a property of a behavior: set the behavior property value Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $component->property = $value;.
또한 보기: __get()
public __set ( string $name, mixed $value )
$name string the property name or the event name
$value mixed the property value

__unset() 공개 메소드

This method will check in the following order and act accordingly: - a property defined by a setter: set the property value to be null - a property of a behavior: set the property value to be null Do not call this method directly as it is a PHP magic method that will be implicitly called when executing unset($component->property).
또한 보기: http://php.net/manual/en/function.unset.php
public __unset ( string $name )
$name string the property name

attachBehavior() 공개 메소드

This method will create the behavior object based on the given configuration. After that, the behavior object will be attached to this component by calling the [[Behavior::attach()]] method.
또한 보기: detachBehavior()
public attachBehavior ( string $name, string | array | Behavior $behavior ) : Behavior
$name string the name of the behavior.
$behavior string | array | Behavior the behavior configuration. This can be one of the following: - a [[Behavior]] object - a string specifying the behavior class - an object configuration array that will be passed to [[Yii::createObject()]] to create the behavior object.
리턴 Behavior the behavior object

attachBehaviors() 공개 메소드

Each behavior is indexed by its name and should be a Behavior object, a string specifying the behavior class, or an configuration array for creating the behavior.
또한 보기: attachBehavior()
public attachBehaviors ( array $behaviors )
$behaviors array list of behaviors to be attached to the component

behaviors() 공개 메소드

Child classes may override this method to specify the behaviors they want to behave as. The return value of this method should be an array of behavior objects or configurations indexed by behavior names. A behavior configuration can be either a string specifying the behavior class or an array of the following structure: php 'behaviorName' => [ 'class' => 'BehaviorClass', 'property1' => 'value1', 'property2' => 'value2', ] Note that a behavior class must extend from Behavior. Behaviors can be attached using a name or anonymously. When a name is used as the array key, using this name, the behavior can later be retrieved using Component::getBehavior or be detached using Component::detachBehavior. Anonymous behaviors can not be retrieved or detached. Behaviors declared in this method will be attached to the component automatically (on demand).
public behaviors ( ) : array
리턴 array the behavior configurations.

canGetProperty() 공개 메소드

A property can be read if: - the class has a getter method associated with the specified name (in this case, property name is case-insensitive); - the class has a member variable with the specified name (when $checkVars is true); - an attached behavior has a readable property of the given name (when $checkBehaviors is true).
또한 보기: canSetProperty()
public canGetProperty ( string $name, boolean $checkVars = true, boolean $checkBehaviors = true ) : boolean
$name string the property name
$checkVars boolean whether to treat member variables as properties
$checkBehaviors boolean whether to treat behaviors' properties as properties of this component
리턴 boolean whether the property can be read

canSetProperty() 공개 메소드

A property can be written if: - the class has a setter method associated with the specified name (in this case, property name is case-insensitive); - the class has a member variable with the specified name (when $checkVars is true); - an attached behavior has a writable property of the given name (when $checkBehaviors is true).
또한 보기: canGetProperty()
public canSetProperty ( string $name, boolean $checkVars = true, boolean $checkBehaviors = true ) : boolean
$name string the property name
$checkVars boolean whether to treat member variables as properties
$checkBehaviors boolean whether to treat behaviors' properties as properties of this component
리턴 boolean whether the property can be written

detachBehavior() 공개 메소드

The behavior's [[Behavior::detach()]] method will be invoked.
public detachBehavior ( string $name ) : null | Behavior
$name string the behavior's name.
리턴 null | Behavior the detached behavior. Null if the behavior does not exist.

detachBehaviors() 공개 메소드

Detaches all behaviors from the component.
public detachBehaviors ( )

ensureBehaviors() 공개 메소드

Makes sure that the behaviors declared in Component::behaviors are attached to this component.
public ensureBehaviors ( )

getBehavior() 공개 메소드

Returns the named behavior object.
public getBehavior ( string $name ) : null | Behavior
$name string the behavior name
리턴 null | Behavior the behavior object, or null if the behavior does not exist

getBehaviors() 공개 메소드

Returns all behaviors attached to this component.
public getBehaviors ( ) : Behavior[]
리턴 Behavior[] list of behaviors attached to this component

hasEventHandlers() 공개 메소드

Returns a value indicating whether there is any handler attached to the named event.
public hasEventHandlers ( string $name ) : boolean
$name string the event name
리턴 boolean whether there is any handler attached to the event.

hasMethod() 공개 메소드

A method is defined if: - the class has a method with the specified name - an attached behavior has a method with the given name (when $checkBehaviors is true).
public hasMethod ( string $name, boolean $checkBehaviors = true ) : boolean
$name string the property name
$checkBehaviors boolean whether to treat behaviors' methods as methods of this component
리턴 boolean whether the property is defined

hasProperty() 공개 메소드

A property is defined if: - the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive); - the class has a member variable with the specified name (when $checkVars is true); - an attached behavior has a property of the given name (when $checkBehaviors is true).
또한 보기: canGetProperty()
또한 보기: canSetProperty()
public hasProperty ( string $name, boolean $checkVars = true, boolean $checkBehaviors = true ) : boolean
$name string the property name
$checkVars boolean whether to treat member variables as properties
$checkBehaviors boolean whether to treat behaviors' properties as properties of this component
리턴 boolean whether the property is defined

off() 공개 메소드

This method is the opposite of Component::on.
또한 보기: on()
public off ( string $name, callable $handler = null ) : boolean
$name string event name
$handler callable the event handler to be removed. If it is null, all handlers attached to the named event will be removed.
리턴 boolean if a handler is found and detached

on() 공개 메소드

The event handler must be a valid PHP callback. The following are some examples: function ($event) { ... } // anonymous function [$object, 'handleClick'] // $object->handleClick() ['Page', 'handleClick'] // Page::handleClick() 'handleClick' // global function handleClick() The event handler must be defined with the following signature, function ($event) where $event is an Event object which includes parameters associated with the event.
또한 보기: off()
public on ( string $name, callable $handler, mixed $data = null, boolean $append = true )
$name string the event name
$handler callable the event handler
$data mixed the data to be passed to the event handler when the event is triggered. When the event handler is invoked, this data can be accessed via [[Event::data]].
$append boolean whether to append new event handler to the end of the existing handler list. If false, the new handler will be inserted at the beginning of the existing handler list.

trigger() 공개 메소드

This method represents the happening of an event. It invokes all attached handlers for the event including class-level handlers.
public trigger ( string $name, Event $event = null )
$name string the event name
$event Event the event parameter. If not set, a default [[Event]] object will be created.