public function setupFieldAssociations($fields, $table, $model, $strategy)
{
$targetAlias = $this->_translationTable->alias();
$alias = $this->_table->alias();
$filter = $this->_config['onlyTranslated'];
$tableLocator = $this->tableLocator();
foreach ($fields as $field) {
$name = $alias . '_' . $field . '_translation';
if (!$tableLocator->exists($name)) {
$fieldTable = $tableLocator->get($name, ['className' => $table, 'alias' => $name, 'table' => $this->_translationTable->table()]);
} else {
$fieldTable = $tableLocator->get($name);
}
$conditions = [$name . '.model' => $model, $name . '.field' => $field];
if (!$this->_config['allowEmptyTranslations']) {
$conditions[$name . '.content !='] = '';
}
$this->_table->hasOne($name, ['targetTable' => $fieldTable, 'foreignKey' => 'foreign_key', 'joinType' => $filter ? 'INNER' : 'LEFT', 'conditions' => $conditions, 'propertyName' => $field . '_translation']);
}
$conditions = ["{$targetAlias}.model" => $model];
if (!$this->_config['allowEmptyTranslations']) {
$conditions["{$targetAlias}.content !="] = '';
}
$this->_table->hasMany($targetAlias, ['className' => $table, 'foreignKey' => 'foreign_key', 'strategy' => $strategy, 'conditions' => $conditions, 'propertyName' => '_i18n', 'dependent' => true]);
}