You are here

function lingotek_test_lingotek_config_entity_translation_presave in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  2. 4.0.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  3. 3.0.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  4. 3.1.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  5. 3.2.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  6. 3.3.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  7. 3.4.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  8. 3.5.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  9. 3.6.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  10. 3.7.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()
  11. 3.8.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_config_entity_translation_presave()

Implements hook_lingotek_content_entity_translation_presave().

File

tests/modules/lingotek_test/lingotek_test.module, line 38

Code

function lingotek_test_lingotek_config_entity_translation_presave(ConfigEntityInterface &$translation, $langcode, &$data) {
  switch ($translation
    ->getEntityTypeId()) {
    case 'block':

      // Decode all [tokens].
      $yaml = Yaml::encode($data);
      $yaml = preg_replace_callback('/\\[\\*\\*\\*([^]]+)\\*\\*\\*\\]/', function ($matches) {
        return '[' . base64_decode($matches[1]) . ']';
      }, $yaml);
      $data = Yaml::decode($yaml);
      break;
  }
}