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
Mostrar archivo Open project: rainlab/translate-plugin

Protected Properties

Property Type Description
$translatableViewBag Data store for translated viewbag attributes.

Public Methods

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

Protected Methods

Method 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 method

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

createModel() protected method

Internal method, prepare the form model object
protected createModel ( ) : Model
return Model

getCmsObjectForLocale() protected method

protected getCmsObjectForLocale ( $locale )

getTranslatableModelClass() public method

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

isEmptyDataSet() protected method

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

loadTranslatableData() protected method

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

mergeViewBagAttributes() protected method

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

overrideTwigCacheKey() protected method

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

storeTranslatableData() protected method

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

syncTranslatableAttributes() public method

{@inheritDoc}

syncTranslatableFileNames() protected method

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