Class lispa\amos\translation\behaviors\TranslateableBehavior
Inheritance | lispa\amos\translation\behaviors\TranslateableBehavior » yii\base\Behavior » yii\base\Object |
---|---|
Implements | yii\base\Configurable |
Public Properties
Public Methods
Protected Methods
Method | Description | Defined By |
---|---|---|
getActiveLanguages() | Return array of languages | lispa\amos\translation\behaviors\TranslateableBehavior |
getModelTranslation() | lispa\amos\translation\behaviors\TranslateableBehavior |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
DELETE_ALL | 1 | lispa\amos\translation\behaviors\TranslateableBehavior | |
DELETE_ONLY_LANGUAGE_SELECTED | 0 | lispa\amos\translation\behaviors\TranslateableBehavior |
Property Details
The language field used in the related table. Determines the language to query | save.
The name of the translations relation
The list of attributes to translate. You can add validation rules on the owner.
Method Details
Make $translationAttributes readable
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
public mixed __get ( $name ) | ||
$name | string | The property name |
return | mixed | The property value |
---|---|---|
throws | yii\base\UnknownPropertyException | if the property is not defined |
throws | yii\base\InvalidCallException | if the property is write-only |
Make $translationAttributes writable
public void __set ( $name, $value ) | ||
$name | ||
$value |
public void afterFind ( $event ) | ||
$event | yii\base\Event |
public void afterInit ( $event ) | ||
$event | yii\base\Event |
public void afterInsert ( $event ) | ||
$event | yii\base\Event |
public void afterUpdate ( $event ) | ||
$event | yii\base\Event |
Expose $translationAttributes readable
A property is readable 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);
public boolean canGetProperty ( $name, $checkVars = true ) | ||
$name | string | The property name |
$checkVars | boolean | Whether to treat member variables as properties |
return | boolean | Whether the property can be read |
---|
Expose $translationAttributes writable
A property is writable 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);
public boolean canSetProperty ( $name, $checkVars = true ) | ||
$name | string | The property name |
$checkVars | boolean | Whether to treat member variables as properties |
return | boolean | Whether the property can be written |
---|
Declares event handlers for the $owner's events.
Child classes may override this method to declare what PHP callbacks should be attached to the events of the $owner component.
The callbacks will be attached to the $owner's events when the behavior is attached to the owner; and they will be detached from the events when the behavior is detached from the component.
The callbacks can be any of the following:
- method in this behavior:
'handleClick'
, equivalent to[$this, 'handleClick']
- object method:
[$object, 'handleClick']
- static method:
['Page', 'handleClick']
- anonymous function:
function ($event) { ... }
The following is an example:
[
Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate',
Model::EVENT_AFTER_VALIDATE => 'myAfterValidate',
]
public array events ( ) | ||
return | array | Events (array keys) and the corresponding event handler methods (array values). |
---|
Return array of languages
protected array getActiveLanguages ( ) |
Returns current models' language. If null, will return app's configured language.
public string getLanguage ( ) |
protected void getModelTranslation ( ) |
Returns a related translation model
public yii\db\ActiveRecord getTranslation ( $language = null, $save = false ) | ||
$language | string|null | The language to return. If null, current sys language |
$save |
public void init ( ) |
Loads all specified languages. For example:
$model->loadTranslations("en-US");
$model->loadTranslations(["en-US", "es-ES"]);
public void loadTranslations ( $languages ) | ||
$languages | string|array |
Saves current translation model
public boolean saveTranslation ( $save = true ) | ||
$save |
Sets current model's language
public void setLanguage ( $value ) | ||
$value |
public void translateOriginalValues ( ) |