PHP 클래스 omgdef\multilingual\MultilingualBehavior

상속: extends yii\base\Behavior
파일 보기 프로젝트 열기: omgdef/yii2-multilingual-behavior 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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