PHP Class RainLab\Translate\Behaviors\TranslatableCmsObject

Usage: In the CMS object class definition: public $implement = ['@RainLab.Translate.Behaviors.TranslatableCmsObject']; public $translatable = ['title', 'markup']; This definition is optional and defaults to RainLab\Translate\Classes\MLCmsObject public $translatableModel = 'RainLab\Translate\Classes\MLStaticPage';
Inheritance: extends RainLab\Translate\Classes\TranslatableBehavior
Afficher le fichier Open project: rainlab/translate-plugin

Protected Properties

Свойство Type Description
$translatableViewBag Data store for translated viewbag attributes.

Méthodes publiques

Méthode Description
__construct ( October\Rain\Database\Model $model ) Constructor
getTranslatableModelClass ( ) : array Returns a collection of fields that will be hashed.
syncTranslatableAttributes ( ) {@inheritDoc}

Méthodes protégées

Méthode Description
createModel ( ) : Model Internal method, prepare the form model object
getCmsObjectForLocale ( $locale )
isEmptyDataSet ( array $data ) : boolean Returns true if all attributes are empty (false when converted to booleans).
loadTranslatableData ( string $locale = null ) : array Loads the translation data from the join table.
mergeViewBagAttributes ( ) : void Merge the viewBag array for the base and translated objects.
overrideTwigCacheKey ( $key ) : string | null Translated CMS objects need their own unique cache key in twig.
storeTranslatableData ( string $locale = null ) : void Saves the translation data in the join table.
syncTranslatableFileNames ( ) If the parent model file name is changed, this should be reflected in the translated models also.

Method Details

__construct() public méthode

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

createModel() protected méthode

Internal method, prepare the form model object
protected createModel ( ) : Model
Résultat Model

getCmsObjectForLocale() protected méthode

protected getCmsObjectForLocale ( $locale )

getTranslatableModelClass() public méthode

Returns a collection of fields that will be hashed.
public getTranslatableModelClass ( ) : array
Résultat array

isEmptyDataSet() protected méthode

Returns true if all attributes are empty (false when converted to booleans).
protected isEmptyDataSet ( array $data ) : boolean
$data array
Résultat boolean

loadTranslatableData() protected méthode

Loads the translation data from the join table.
protected loadTranslatableData ( string $locale = null ) : array
$locale string
Résultat array

mergeViewBagAttributes() protected méthode

Merge the viewBag array for the base and translated objects.
protected mergeViewBagAttributes ( ) : void
Résultat void

overrideTwigCacheKey() protected méthode

Translated CMS objects need their own unique cache key in twig.
protected overrideTwigCacheKey ( $key ) : string | null
Résultat string | null

storeTranslatableData() protected méthode

Saves the translation data in the join table.
protected storeTranslatableData ( string $locale = null ) : void
$locale string
Résultat void

syncTranslatableAttributes() public méthode

{@inheritDoc}

syncTranslatableFileNames() protected méthode

If the parent model file name is changed, this should be reflected in the translated models also.

Property Details

$translatableViewBag protected_oe property

Data store for translated viewbag attributes.
protected $translatableViewBag