public function LingotekConfigManagementForm::debugExport in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 4.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.1.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.2.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.3.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.4.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.5.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.6.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.7.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
- 3.8.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::debugExport()
Export source for debugging purposes.
Parameters
\Drupal\config_translation\ConfigMapperInterface $mapper: The mapper.
File
- src/
Form/ LingotekConfigManagementForm.php, line 565 - Contains \Drupal\Lingotek\Form\LingotekConfigManagementForm.
Class
- LingotekConfigManagementForm
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
public function debugExport(ConfigMapperInterface $mapper, $language, &$context) {
$context['message'] = $this
->t('Exporting %label.', [
'%label' => $mapper
->getTitle(),
]);
if ($profile = $this->lingotekConfiguration
->getConfigProfile($mapper
->getPluginId(), FALSE) or TRUE) {
$data = $this->translationService
->getConfigSourceData($mapper);
$data['_debug'] = [
'title' => trim($mapper
->getPluginId() . ' (config): ' . $mapper
->getTitle()),
'profile' => $profile ? $profile
->id() : '<null>',
'source_locale' => $this->translationService
->getConfigSourceLocale($mapper),
];
$filename = 'config.' . $mapper
->getPluginId() . '.json';
$plugin_definition = $mapper
->getPluginDefinition();
if (isset($plugin_definition['entity_type']) && 'field_config' === $plugin_definition['entity_type']) {
$entity = $mapper
->getEntity();
$data['_debug']['title'] = $entity
->id() . ' (config): ' . $entity
->label();
$filename = 'config.' . $entity
->id() . '.json';
}
$source_data = json_encode($data);
$file = File::create([
'uid' => 1,
'filename' => $filename,
'uri' => 'public://' . $filename,
'filemime' => 'text/plain',
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
]);
file_put_contents($file
->getFileUri(), $source_data);
$file
->save();
$context['results']['exported'][] = $file
->id();
}
else {
drupal_set_message($this
->t('The %label has no profile assigned so it was not processed.', [
'%label' => $mapper
->getTitle(),
]), 'warning');
}
}