Skip to content

Commit

Permalink
[DOC] Explain flux parent assignment for translations
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelbrackets committed Oct 13, 2016
1 parent 039f9bf commit b074695
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Classes/Service/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,18 @@ public function initializeRecord($id, array &$row, DataHandler $tceMain) {
*/
protected function initializeRecordByNewAndOldAndLanguageUids($row, $newUid, $oldUid, $newLanguageUid, $languageFieldName, DataHandler $tceMain) {
if (0 < $newUid && 0 < $oldUid && 0 < $newLanguageUid) {
// Get the origin record of the current record to find out if it has any
// parameters we need to adapt in the current record.
$oldRecord = $this->loadRecordFromDatabase($oldUid);
if ($oldRecord[$languageFieldName] !== $newLanguageUid && $oldRecord['pid'] === $row['pid'] && MathUtility::canBeInterpretedAsInteger($oldRecord['tx_flux_parent']) && $oldRecord['tx_flux_parent'] > 0) {
// look for the translated version of the parent record indicated
// in this new, translated record. Below, we adjust the parent UID
// so it has the UID of the translated parent if one exists.
$translatedParents = (array) $this->workspacesAwareRecordService->get('tt_content', 'uid,sys_language_uid', "t3_origuid = '" . $oldRecord['tx_flux_parent'] . "'" . BackendUtility::deleteClause('tt_content'));
// If the origin record has a flux parent assigned, then look for the
// translated, very last version this parent record and, if any valid record was found,
// assign its UID as flux parent to the current record.
$translatedParents = (array) $this->workspacesAwareRecordService->get(
'tt_content',
'uid,sys_language_uid',
't3_origuid=' . $oldRecord['tx_flux_parent'] . BackendUtility::deleteClause('tt_content')
);
foreach ($translatedParents as $translatedParent) {
if ($translatedParent['sys_language_uid'] == $newLanguageUid) {
// set $translatedParent to the right language ($newLanguageUid):
Expand Down

0 comments on commit b074695

Please sign in to comment.