Contains common code needed by TranslateBehavior strategy classes.
string|null
The locale name that will be used to override fields in the bound table from the translations table
Cake\ORM\Table
Table instance
Cake\ORM\Table
Instance of Table responsible for translating
Unsets the temporary _i18n
property after the entity has been saved
Build a set of properties that should be included in the marshalling process.
Returns the current locale.
Return translation table instance.
Sets the locale to be used.
Unset empty translations to avoid persistence.
afterSave(Cake\Event\EventInterface $event, Cake\Datasource\EntityInterface $entity): void
Unsets the temporary _i18n
property after the entity has been saved
Cake\Event\EventInterface
$event The beforeSave event that was fired
Cake\Datasource\EntityInterface
$entity The entity that is going to be saved
void
buildMarshalMap(Cake\ORM\Marshaller $marshaller, array $map, array<string, mixed> $options): array
Build a set of properties that should be included in the marshalling process.
Add in _translations
marshalling handlers. You can disable marshalling of translations by setting 'translations' => false
in the options provided to Table::newEntity()
or Table::patchEntity()
.
Cake\ORM\Marshaller
$marshaller The marhshaller of the table the behavior is attached to.
array
$map The property map being built.
array<string, mixed>
$options The options array used in the marshalling call.
array
getLocale(): string
Returns the current locale.
If no locale has been explicitly set via setLocale()
, this method will return the currently configured global locale.
string
getTranslationTable(): Cake\ORM\Table
Return translation table instance.
Cake\ORM\Table
setLocale(string|null $locale): $this
Sets the locale to be used.
When fetching records, the content for the locale set via this method, and likewise when saving data, it will save the data in that locale.
Note that in case an entity has a _locale
property set, that locale will win over the locale set via this method (and over the globally configured one for that matter)!
string|null
$locale The locale to use for fetching and saving records. Pass null
in order to unset the current locale, and to make the behavior fall back to using the globally configured locale.
$this
unsetEmptyFields(Cake\Datasource\EntityInterface $entity): void
Unset empty translations to avoid persistence.
Should only be called if $this->_config['allowEmptyTranslations'] is false.
Cake\Datasource\EntityInterface
$entity The entity to check for empty translations fields inside.
void
The locale name that will be used to override fields in the bound table from the translations table
string|null
Table instance
Cake\ORM\Table
Instance of Table responsible for translating
Cake\ORM\Table
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/trait-Cake.ORM.Behavior.Translate.TranslateStrategyTrait.html