Created
January 21, 2022 15:36
-
-
Save Tuurlijk/34d989e86d5e4235d9069a1a18f4a293 to your computer and use it in GitHub Desktop.
Populate l10n_state field of tt_content records when creating a translation. So the radio buttons for allowLanguageSynchronization are set to 'custom value' by default.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Some\Client\Hooks; | |
/** | |
* DataHandler | |
* | |
* Contains hooks for the \TYPO3\CMS\Core\DataHandling\DataHandler class | |
*/ | |
class DataHandler | |
{ | |
/** | |
* Populate l10n_state field of tt_content records when creating a translation. So the radio buttons for | |
* allowLanguageSynchronization are set to 'custom value' by default. | |
* | |
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler | |
*/ | |
public function processDatamap_beforeStart(\TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler): void | |
{ | |
if (empty($dataHandler->datamap['tt_content'])) { | |
return; | |
} | |
foreach ($dataHandler->datamap['tt_content'] as $id => $record) { | |
if (strpos($id, 'NEW') === false) { | |
continue; | |
} | |
$l10n_state = '{"image": "custom"}'; | |
if ($record['l10n_state']) { | |
$defaultState = json_decode($record['l10n_state'], true); | |
$defaultState['image'] = 'custom'; | |
$l10n_state = json_encode($defaultState, JSON_FORCE_OBJECT); | |
} | |
$record['l10n_state'] = $l10n_state; | |
$dataHandler->datamap['tt_content'][$id] = $record; | |
} | |
} | |
} |
Author
Tuurlijk
commented
Jan 21, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment