PHP Класс yii\base\Component

Наследование: extends Object
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.