PHP 클래스 RainLab\Translate\Classes\TranslatableBehavior

저자: Alexey Bobkov, Samuel Georges
상속: extends October\Rain\Extension\ExtensionBase
파일 보기 프로젝트 열기: rainlab/translate-plugin 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$model Reference to the extended model.
$requiredProperties {@inheritDoc}
$translatableAttributes Data store for translated attributes.
$translatableContext Active language for translations.
$translatableDefault Default system language.
$translatableOriginals Data store for original translated attributes.
$translatableUseFallback Determines if empty translations should be replaced by default values.

공개 메소드들

메소드 설명
__construct ( October\Rain\Database\Model $model ) Constructor
getAttributeTranslated ( string $key, string $locale = null ) : string Returns a translated attribute value.
getTranslatableAttributes ( ) : array Returns a collection of fields that will be hashed.
getTranslatableAttributesWithOptions ( ) : array Returns the defined options for a translatable attribute.
getTranslateAttribute ( $key, $locale = null )
getTranslateAttributes ( string $locale ) : array Returns all translated attribute values.
getTranslateDirty ( $locale = null ) : array Get the translated attributes that have been changed since last sync.
hasTransatableAttributes ( ) : true Checks if this model has transatable attributes.
hasTranslation ( string $key, string $locale ) : boolean Returns whether the attribute is translatable (has a translation) for the given locale.
initTranslatableContext ( ) : void Initializes this class, sets the default language code to use.
isTranslatable ( string $key ) : boolean Checks if an attribute should be translated or not.
isTranslateDirty ( string | null $attribute = null, $locale = null ) : boolean Determine if the model or a given translated attribute has been modified.
lang ( string $context = null ) : self Shorthand for translateContext method, and chainable.
noFallbackLocale ( ) : self Disables translation fallback locale.
setAttributeTranslated ( string $key, string $value, $locale = null ) : string Sets a translated attribute value.
setTranslateAttribute ( $key, $value, $locale = null )
syncTranslatableAttributes ( ) : void Restores the default language values on the model and stores the translated values in the attributes table.
translateContext ( string $context = null ) : void Changes the active language for this model

보호된 메소드들

메소드 설명
getAttributeFromData ( mixed $data, string $attribute ) : mixed Extracts a attribute from a model/array with nesting support.
loadTranslatableData ( string $locale = null ) : array Loads the translation data from the model.
setAttributeFromData ( mixed &$data, string $attribute, $value ) : mixed Sets an attribute from a model/array with nesting support.
storeTranslatableData ( string $locale = null ) : void Saves the translation data for the model.

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( October\Rain\Database\Model $model )
$model October\Rain\Database\Model The extended model.

getAttributeFromData() 보호된 메소드

Extracts a attribute from a model/array with nesting support.
protected getAttributeFromData ( mixed $data, string $attribute ) : mixed
$data mixed
$attribute string
리턴 mixed

getAttributeTranslated() 공개 메소드

The base value must come from 'attributes' on the model otherwise the process can possibly loop back to this event, then method triggered by __get() magic.
public getAttributeTranslated ( string $key, string $locale = null ) : string
$key string
$locale string
리턴 string

getTranslatableAttributes() 공개 메소드

Returns a collection of fields that will be hashed.
public getTranslatableAttributes ( ) : array
리턴 array

getTranslatableAttributesWithOptions() 공개 메소드

Returns the defined options for a translatable attribute.

getTranslateAttribute() 공개 메소드

사용 중단: getTranslateAttribute is deprecated, use getAttributeTranslated instead.
public getTranslateAttribute ( $key, $locale = null )

getTranslateAttributes() 공개 메소드

Returns all translated attribute values.
public getTranslateAttributes ( string $locale ) : array
$locale string
리턴 array

getTranslateDirty() 공개 메소드

Get the translated attributes that have been changed since last sync.
public getTranslateDirty ( $locale = null ) : array
리턴 array

hasTransatableAttributes() 공개 메소드

Checks if this model has transatable attributes.
public hasTransatableAttributes ( ) : true
리턴 true

hasTranslation() 공개 메소드

Returns whether the attribute is translatable (has a translation) for the given locale.
public hasTranslation ( string $key, string $locale ) : boolean
$key string
$locale string
리턴 boolean

initTranslatableContext() 공개 메소드

Initializes this class, sets the default language code to use.
public initTranslatableContext ( ) : void
리턴 void

isTranslatable() 공개 메소드

Checks if an attribute should be translated or not.
public isTranslatable ( string $key ) : boolean
$key string
리턴 boolean

isTranslateDirty() 공개 메소드

Determine if the model or a given translated attribute has been modified.
public isTranslateDirty ( string | null $attribute = null, $locale = null ) : boolean
$attribute string | null
리턴 boolean

lang() 공개 메소드

Shorthand for translateContext method, and chainable.
public lang ( string $context = null ) : self
$context string
리턴 self

loadTranslatableData() 추상적인 보호된 메소드

Loads the translation data from the model.
abstract protected loadTranslatableData ( string $locale = null ) : array
$locale string
리턴 array

noFallbackLocale() 공개 메소드

Disables translation fallback locale.
public noFallbackLocale ( ) : self
리턴 self

setAttributeFromData() 보호된 메소드

Sets an attribute from a model/array with nesting support.
protected setAttributeFromData ( mixed &$data, string $attribute, $value ) : mixed
$data mixed
$attribute string
리턴 mixed

setAttributeTranslated() 공개 메소드

Sets a translated attribute value.
public setAttributeTranslated ( string $key, string $value, $locale = null ) : string
$key string Attribute
$value string Value to translate
리턴 string Translated value

setTranslateAttribute() 공개 메소드

사용 중단: setTranslateAttribute is deprecated, use setAttributeTranslated instead.
public setTranslateAttribute ( $key, $value, $locale = null )

storeTranslatableData() 추상적인 보호된 메소드

Saves the translation data for the model.
abstract protected storeTranslatableData ( string $locale = null ) : void
$locale string
리턴 void

syncTranslatableAttributes() 공개 메소드

Restores the default language values on the model and stores the translated values in the attributes table.
public syncTranslatableAttributes ( ) : void
리턴 void

translateContext() 공개 메소드

Changes the active language for this model
public translateContext ( string $context = null ) : void
$context string
리턴 void

프로퍼티 상세

$model 보호되어 있는 프로퍼티

Reference to the extended model.
protected $model

$requiredProperties 보호되어 있는 프로퍼티

{@inheritDoc}
protected $requiredProperties

$translatableAttributes 보호되어 있는 프로퍼티

Data store for translated attributes.
protected $translatableAttributes

$translatableContext 보호되어 있는 프로퍼티

Active language for translations.
protected $translatableContext

$translatableDefault 보호되어 있는 프로퍼티

Default system language.
protected $translatableDefault

$translatableOriginals 보호되어 있는 프로퍼티

Data store for original translated attributes.
protected $translatableOriginals

$translatableUseFallback 보호되어 있는 프로퍼티

Determines if empty translations should be replaced by default values.
protected $translatableUseFallback