This interface describes the methods for translate behavior strategies.
Callback method that listens to the beforeFind
event in the bound table. It modifies the passed query by eager loading the translated fields and adding a formatter to copy the values into the main table records.
Modifies the entity before it is saved so that translated fields are persisted in the database too.
Build a set of properties that should be included in the marshalling process.
Modifies the results from a table find in order to merge full translation records into each entity under the _translations
key
afterSave(\Cake\Event\EventInterface $event, \Cake\Datasource\EntityInterface $entity)
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
beforeFind(\Cake\Event\EventInterface $event, \Cake\ORM\Query $query, \ArrayObject $options)
Callback method that listens to the beforeFind
event in the bound table. It modifies the passed query by eager loading the translated fields and adding a formatter to copy the values into the main table records.
\Cake\Event\EventInterface
$event The beforeFind event that was fired.
\Cake\ORM\Query
$query Query
\ArrayObject
$options The options for the query
beforeSave(\Cake\Event\EventInterface $event, \Cake\Datasource\EntityInterface $entity, \ArrayObject $options)
Modifies the entity before it is saved so that translated fields are persisted in the database too.
\Cake\Event\EventInterface
$event The beforeSave event that was fired
\Cake\Datasource\EntityInterface
$entity The entity that is going to be saved
\ArrayObject
$options the options passed to the save method
buildMarshalMap(\Cake\ORM\Marshaller $marshaller, array $map, array $options)
Build a set of properties that should be included in the marshalling process.
\Cake\ORM\Marshaller
$marshaller The marhshaller of the table the behavior is attached to.
array
$map The property map being built.
array
$options The options array used in the marshalling call.
array
A map of [property => callable]
of additional properties to marshal.
getLocale()
Returns the current locale.
If no locale has been explicitly set via setLocale()
, this method will return the currently configured global locale.
string
getTranslationTable()
Return translation table instance.
\Cake\ORM\Table
groupTranslations(mixed $results)
Modifies the results from a table find in order to merge full translation records into each entity under the _translations
key
\Cake\Datasource\ResultSetInterface
$results Results to modify.
\Cake\Collection\CollectionInterface
setLocale(?string $locale)
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
translationField(string $field)
Returns a fully aliased field name for translated fields.
If the requested field is configured as a translation field, field with an alias of a corresponding association is returned. Table-aliased field name is returned for all other fields.
string
$field Field name to be aliased.
string
© 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.1/interface-Cake.ORM.Behavior.Translate.TranslateStrategyInterface.html