mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #2728 from joostdekeijzer/2721-fix-in-translatebehavior
Fix Model::field() and TranslateBehavior::beforeFind() not working together. Fixes #2721
This commit is contained in:
commit
5629dfdcc3
2 changed files with 28 additions and 0 deletions
|
@ -139,6 +139,8 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
}
|
}
|
||||||
unset($this->_joinTable, $this->_runtimeModel);
|
unset($this->_joinTable, $this->_runtimeModel);
|
||||||
return $query;
|
return $query;
|
||||||
|
} elseif (is_string($query['fields'])) {
|
||||||
|
$query['fields'] = String::tokenize($query['fields']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = array_merge(
|
$fields = array_merge(
|
||||||
|
|
|
@ -232,6 +232,32 @@ class TranslateBehaviorTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $TestModel->field('title', array('TranslatedItem.id' => 1));
|
||||||
|
$expected = 'Title #1';
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $TestModel->read('title', 1);
|
||||||
|
$expected = array(
|
||||||
|
'TranslatedItem' => array(
|
||||||
|
'id' => 1,
|
||||||
|
'slug' => 'first_translated',
|
||||||
|
'locale' => 'eng',
|
||||||
|
'title' => 'Title #1',
|
||||||
|
'translated_article_id' => 1,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $TestModel->read('id, title', 1);
|
||||||
|
$expected = array(
|
||||||
|
'TranslatedItem' => array(
|
||||||
|
'id' => 1,
|
||||||
|
'locale' => 'eng',
|
||||||
|
'title' => 'Title #1',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue