"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/ORM/Behavior/Translate/TranslateStrategyTrait.php" between
cakephp-4.2.2.tar.gz and cakephp-4.2.3.tar.gz

About: CakePHP is a rapid development framework for PHP applications. Source code.

TranslateStrategyTrait.php  (cakephp-4.2.2):TranslateStrategyTrait.php  (cakephp-4.2.3)
skipping to change at line 114 skipping to change at line 114
* @param \Cake\Datasource\EntityInterface $entity The entity to check for e mpty translations fields inside. * @param \Cake\Datasource\EntityInterface $entity The entity to check for e mpty translations fields inside.
* @return void * @return void
*/ */
protected function unsetEmptyFields($entity) protected function unsetEmptyFields($entity)
{ {
/** @var \Cake\ORM\Entity[] $translations */ /** @var \Cake\ORM\Entity[] $translations */
$translations = (array)$entity->get('_translations'); $translations = (array)$entity->get('_translations');
foreach ($translations as $locale => $translation) { foreach ($translations as $locale => $translation) {
$fields = $translation->extract($this->_config['fields'], false); $fields = $translation->extract($this->_config['fields'], false);
foreach ($fields as $field => $value) { foreach ($fields as $field => $value) {
if (strlen($value) === 0) { if ($value === null || $value === '') {
$translation->unset($field); $translation->unset($field);
} }
} }
$translation = $translation->extract($this->_config['fields']); $translation = $translation->extract($this->_config['fields']);
// If now, the current locale property is empty, // If now, the current locale property is empty,
// unset it completely. // unset it completely.
if (empty(array_filter($translation))) { if (empty(array_filter($translation))) {
unset($entity->get('_translations')[$locale]); unset($entity->get('_translations')[$locale]);
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)