Class yeesoft\behaviors\MultilingualSettingsBehavior

Inheritanceyeesoft\behaviors\MultilingualSettingsBehavior » yii\base\Behavior

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$abridge boolean Whether to abridge the language ID. yeesoft\behaviors\MultilingualSettingsBehavior
$attributes array yeesoft\behaviors\MultilingualSettingsBehavior
$defaultLanguage string The default language. yeesoft\behaviors\MultilingualSettingsBehavior
$dynamicLangClass boolean Whether to dynamically create translation model class. yeesoft\behaviors\MultilingualSettingsBehavior
$forceDelete boolean Whether to force deletion of the associated translations when a base model is deleted. yeesoft\behaviors\MultilingualSettingsBehavior
$languageField string The name of the lang field of the translation table. yeesoft\behaviors\MultilingualSettingsBehavior
$languages array yeesoft\behaviors\MultilingualSettingsBehavior
$localizedPrefix string The prefix of the localized attributes in the lang table. yeesoft\behaviors\MultilingualSettingsBehavior
$requireTranslations boolean If this property is set to true required validators will be applied to all translation models. yeesoft\behaviors\MultilingualSettingsBehavior
$tableName string The name of the translation table yeesoft\behaviors\MultilingualSettingsBehavior

Property Details

$abridge public property

Whether to abridge the language ID. Default to true.

public boolean $abridge false
$attributes public property
public array $attributes null
$defaultLanguage public property

The default language. Example: 'en'.

public string $defaultLanguage null
$dynamicLangClass public property

Whether to dynamically create translation model class. If true, the translation model class will be generated on runtime with the use of the eval() function so no additional php file is needed. See {@link createLangClass()} Default to true.

public boolean $dynamicLangClass true
$forceDelete public property

Whether to force deletion of the associated translations when a base model is deleted. Not needed if using foreign key with 'on delete cascade'. Default to true.

public boolean $forceDelete true
$languageField public property

The name of the lang field of the translation table. Default to 'language'.

public string $languageField 'language'
$languages public property
public array $languages null
$localizedPrefix public property

The prefix of the localized attributes in the lang table. Here to avoid collisions in queries. In the translation table, the columns corresponding to the localized attributes have to be name like this: 'l_[name of the attribute]' and the id column (primary key) like this : 'l_id' Default to ''.

$requireTranslations public property

If this property is set to true required validators will be applied to all translation models. Default to false.

$tableName public property

The name of the translation table

public string $tableName null

Method Details

afterFind() public method

Handle 'afterFind' event of the owner.

public void afterFind ( )
attach() public method

public void attach ( $owner )
$owner

Yeesoft\settings\models\BaseSettingsModel

beforeValidate() public method

Handle 'beforeValidate' event of the owner.

public void beforeValidate ( )
events() public method

public void events ( )
getAttributeName() protected method

protected string getAttributeName ( $attribute, $language )
$attribute
$language
getCurrentLanguage() public method

public mixed|string getCurrentLanguage ( )
getLangAttribute() public method

public string getLangAttribute ( $name )
$name string

The name of the attribute

return string

The attribute value

getLanguageSubtag() protected method

Extract language two-letter abbreviation (ISO 639-1) from language key.

protected string getLanguageSubtag ( $language )
$language
hasLangAttribute() public method

Whether an attribute exists

public boolean hasLangAttribute ( $name )
$name string

The name of the attribute

indexByLanguage() protected method

protected array indexByLanguage ( $records )
$records
init() public method

public void init ( )
setLangAttribute() public method

public void setLangAttribute ( $name, $value )
$name string

The name of the attribute

$value string

The value of the attribute