function hook_lingotek_config_entity_document_upload in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 4.0.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.0.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.1.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.2.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.3.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.4.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.5.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.6.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.7.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
- 3.8.x lingotek.api.php \hook_lingotek_config_entity_document_upload()
Act on the data extracted from a config entity before it is uploaded to Lingotek.
Parameters
array &$source_data: The data that will be uploaded, as an associative array.
\Drupal\Core\Config\Entity\ConfigEntityInterface &$entity: The config entity where the data is extracted from and will be associated to the Lingotek document.
string &$url: The url which will be associated to this document, e.g. for context review.
Related topics
1 function implements hook_lingotek_config_entity_document_upload()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- lingotek_test_lingotek_config_entity_document_upload in tests/
modules/ lingotek_test/ lingotek_test.module - Implements hook_lingotek_content_entity_document_upload().
2 invocations of hook_lingotek_config_entity_document_upload()
- LingotekConfigTranslationService::updateDocument in src/
LingotekConfigTranslationService.php - Resends a document to the translation service.
- LingotekConfigTranslationService::uploadDocument in src/
LingotekConfigTranslationService.php - Uploads a document to the Lingotek service.
File
- ./
lingotek.api.php, line 107
Code
function hook_lingotek_config_entity_document_upload(array &$source_data, ConfigEntityInterface &$entity, &$url) {
// In this example, all tokens are being encoded for block config entities.
switch ($entity
->getEntityTypeId()) {
case 'block':
// Encode all [tokens].
$yaml = Yaml::encode($source_data);
$yaml = preg_replace_callback('/\\[([a-z][^]]+)\\]/', function ($matches) {
return '[***' . base64_encode($matches[1]) . '***]';
}, $yaml);
$source_data = Yaml::decode($yaml);
break;
}
}