Class lispa\amos\translation\behaviors\TranslateableBehavior

Inheritancelispa\amos\translation\behaviors\TranslateableBehavior » yii\base\Behavior » yii\base\Object
Implementsyii\base\Configurable

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Make $translationAttributes readable lispa\amos\translation\behaviors\TranslateableBehavior
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Make $translationAttributes writable lispa\amos\translation\behaviors\TranslateableBehavior
__unset() Sets an object property to null. yii\base\Object
afterFind() lispa\amos\translation\behaviors\TranslateableBehavior
afterInit() lispa\amos\translation\behaviors\TranslateableBehavior
afterInsert() lispa\amos\translation\behaviors\TranslateableBehavior
afterUpdate() lispa\amos\translation\behaviors\TranslateableBehavior
attach() Attaches the behavior object to the component. yii\base\Behavior
canGetProperty() Expose $translationAttributes readable lispa\amos\translation\behaviors\TranslateableBehavior
canSetProperty() Expose $translationAttributes writable lispa\amos\translation\behaviors\TranslateableBehavior
className() Returns the fully qualified name of this class. yii\base\Object
detach() Detaches the behavior object from the component. yii\base\Behavior
events() Declares event handlers for the $owner's events. lispa\amos\translation\behaviors\TranslateableBehavior
getLanguage() Returns current models' language. If null, will return app's configured language. lispa\amos\translation\behaviors\TranslateableBehavior
getTranslation() Returns a related translation model lispa\amos\translation\behaviors\TranslateableBehavior
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() lispa\amos\translation\behaviors\TranslateableBehavior
loadTranslations() Loads all specified languages. For example: lispa\amos\translation\behaviors\TranslateableBehavior
saveTranslation() Saves current translation model lispa\amos\translation\behaviors\TranslateableBehavior
setLanguage() Sets current model's language lispa\amos\translation\behaviors\TranslateableBehavior
translateOriginalValues() lispa\amos\translation\behaviors\TranslateableBehavior

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DELETE_ALL 1 lispa\amos\translation\behaviors\TranslateableBehavior
DELETE_ONLY_LANGUAGE_SELECTED 0 lispa\amos\translation\behaviors\TranslateableBehavior

Property Details

$afterDeleteSource public property
public $afterDeleteSource self::DELETE_ALL
$blackListAttributes public property
$defaultLanguage public property
public $defaultLanguage null
$enableValidationAttributes public property
$enableWorkflow public property
public $enableWorkflow false
$forceTranslation public property
public $forceTranslation false
$language public property
public string getLanguage ( )
public void setLanguage ( $value )
$languageField public property

The language field used in the related table. Determines the language to query | save.

public string $languageField 'language'
$pathsTranslation public property
public $pathsTranslation = ['@frontend']
$relation public property

The name of the translations relation

public string $relation 'translations'
$statusWorkflowApproved public property
public $statusWorkflowApproved 'AmosTranslationWorkflow/APPROVED'
$statusWorkflowInitial public property
public $statusWorkflowInitial 'AmosTranslationWorkflow/DRAFT'
$translation public read-only property
public yii\db\ActiveRecord getTranslation ( $language null, $save false )
$translationAttributes public property

The list of attributes to translate. You can add validation rules on the owner.

$workflow public property
public $workflow 'AmosTranslationWorkflow'
$workflowBehavior public property
public $workflowBehavior 'workflow'

Method Details

__get() public method

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

__set() public method

Make $translationAttributes writable

public void __set ( $name, $value )
$name
$value
afterFind() public method

public void afterFind ( $event )
$event yii\base\Event
afterInit() public method

public void afterInit ( $event )
$event yii\base\Event
afterInsert() public method

public void afterInsert ( $event )
$event yii\base\Event
afterUpdate() public method

public void afterUpdate ( $event )
$event yii\base\Event
canGetProperty() public method

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

canSetProperty() public method

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

events() public method

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).

getActiveLanguages() protected method

Return array of languages

protected array getActiveLanguages ( )
getLanguage() public method

Returns current models' language. If null, will return app's configured language.

public string getLanguage ( )
getModelTranslation() protected method

protected void getModelTranslation ( )
getTranslation() public method

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
init() public method

public void init ( )
loadTranslations() public method

Loads all specified languages. For example:

$model->loadTranslations("en-US");

$model->loadTranslations(["en-US", "es-ES"]);

public void loadTranslations ( $languages )
$languages string|array
saveTranslation() public method

Saves current translation model

public boolean saveTranslation ( $save true )
$save
setLanguage() public method

Sets current model's language

public void setLanguage ( $value )
$value
translateOriginalValues() public method

public void translateOriginalValues ( )