PHP Класс omgdef\multilingual\MultilingualBehavior

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

Открытые свойства

Свойство Тип Описание
$abridge whether to abridge the language ID. Default to true.
$attributes array Multilingual attributes
$currentLanguage
$defaultLanguage the default language. Example: 'en'.
$dynamicLangClass 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.
$forceDelete 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.
$langClassName the name of translation model class.
$langClassSuffix if $langClassName is not set, it will be assumed that $langClassName is get_class($this->owner) . $this->langClassSuffix
$langForeignKey the name of the foreign key field of the translation table related to base model table.
$languageField the name of the lang field of the translation table. Default to 'language'.
$languages array Available languages It can be a simple array: array('fr', 'en') or an associative array: array('fr' => 'Français', 'en' => 'English') For associative arrays, only the keys will be used.
$localizedPrefix 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 if this property is set to true required validators will be applied to all translation models. Default to false.
$tableName the name of the translation table

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

Метод Описание
__get ( $name )
__isset ( $name )
__set ( $name, $value )
afterDelete ( ) Handle 'afterDelete' event of the owner.
afterFind ( ) Handle 'afterFind' event of the owner.
afterInsert ( ) Handle 'afterInsert' event of the owner.
afterUpdate ( ) Handle 'afterUpdate' event of the owner.
attach ( $owner )
beforeValidate ( ) Handle 'beforeValidate' event of the owner.
canGetProperty ( $name, $checkVars = true )
canSetProperty ( $name, $checkVars = true )
createLangClass ( )
events ( )
getCurrentLanguage ( ) : mixed | string
getLangAttribute ( string $name ) : string
getTranslation ( $language = null ) : ActiveQuery Relation to model translation
getTranslations ( ) : ActiveQuery Relation to model translations
hasLangAttribute ( string $name ) : boolean Whether an attribute exists
setLangAttribute ( string $name, string $value )

Защищенные методы

Метод Описание
getAttributeName ( $attribute, $language ) : string
getLanguageBaseName ( $language ) : string
indexByLanguage ( $records ) : array

Приватные методы

Метод Описание
getShortClassName ( string $className ) : string
saveTranslations ( array $translations = [] )

Описание методов

__get() публичный Метод

public __get ( $name )

__isset() публичный Метод

public __isset ( $name )

__set() публичный Метод

public __set ( $name, $value )

afterDelete() публичный Метод

Handle 'afterDelete' event of the owner.
public afterDelete ( )

afterFind() публичный Метод

Handle 'afterFind' event of the owner.
public afterFind ( )

afterInsert() публичный Метод

Handle 'afterInsert' event of the owner.
public afterInsert ( )

afterUpdate() публичный Метод

Handle 'afterUpdate' event of the owner.
public afterUpdate ( )

attach() публичный Метод

public attach ( $owner )

beforeValidate() публичный Метод

Handle 'beforeValidate' event of the owner.
public beforeValidate ( )

canGetProperty() публичный Метод

public canGetProperty ( $name, $checkVars = true )

canSetProperty() публичный Метод

public canSetProperty ( $name, $checkVars = true )

createLangClass() публичный Метод

public createLangClass ( )

events() публичный Метод

public events ( )

getAttributeName() защищенный Метод

protected getAttributeName ( $attribute, $language ) : string
$attribute
$language
Результат string

getCurrentLanguage() публичный Метод

public getCurrentLanguage ( ) : mixed | string
Результат mixed | string

getLangAttribute() публичный Метод

public getLangAttribute ( string $name ) : string
$name string the name of the attribute
Результат string the attribute value

getLanguageBaseName() защищенный Метод

protected getLanguageBaseName ( $language ) : string
$language
Результат string

getTranslation() публичный Метод

Relation to model translation
public getTranslation ( $language = null ) : ActiveQuery
$language
Результат yii\db\ActiveQuery

getTranslations() публичный Метод

Relation to model translations
public getTranslations ( ) : ActiveQuery
Результат yii\db\ActiveQuery

hasLangAttribute() публичный Метод

Whether an attribute exists
public hasLangAttribute ( string $name ) : boolean
$name string the name of the attribute
Результат boolean

indexByLanguage() защищенный Метод

protected indexByLanguage ( $records ) : array
$records
Результат array

setLangAttribute() публичный Метод

public setLangAttribute ( string $name, string $value )
$name string the name of the attribute
$value string the value of the attribute

Описание свойств

$abridge публичное свойство

whether to abridge the language ID. Default to true.
public $abridge

$attributes публичное свойство

Multilingual attributes
public array $attributes
Результат array

$currentLanguage публичное свойство

public $currentLanguage

$defaultLanguage публичное свойство

the default language. Example: 'en'.
public $defaultLanguage

$dynamicLangClass публичное свойство

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 $dynamicLangClass

$forceDelete публичное свойство

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 $forceDelete

$langClassName публичное свойство

the name of translation model class.
public $langClassName

$langClassSuffix публичное свойство

if $langClassName is not set, it will be assumed that $langClassName is get_class($this->owner) . $this->langClassSuffix
public $langClassSuffix

$langForeignKey публичное свойство

the name of the foreign key field of the translation table related to base model table.
public $langForeignKey

$languageField публичное свойство

the name of the lang field of the translation table. Default to 'language'.
public $languageField

$languages публичное свойство

Available languages It can be a simple array: array('fr', 'en') or an associative array: array('fr' => 'Français', 'en' => 'English') For associative arrays, only the keys will be used.
public array $languages
Результат array

$localizedPrefix публичное свойство

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 ''.
public $localizedPrefix

$requireTranslations публичное свойство

if this property is set to true required validators will be applied to all translation models. Default to false.
public $requireTranslations

$tableName публичное свойство

the name of the translation table
public $tableName