public function ContentSingleExportForm::updateExport in Content Synchronization 3.0.x
Same name and namespace in other branches
- 8.2 src/Form/ContentSingleExportForm.php \Drupal\content_sync\Form\ContentSingleExportForm::updateExport()
- 8 src/Form/ContentSingleExportForm.php \Drupal\content_sync\Form\ContentSingleExportForm::updateExport()
Handles switching the export textarea.
File
- src/
Form/ ContentSingleExportForm.php, line 166
Class
- ContentSingleExportForm
- Provides a form for exporting a single content file.
Namespace
Drupal\content_sync\FormCode
public function updateExport($form, FormStateInterface $form_state) {
// Get submitted values
$entity_type = $form_state
->getValue('content_type');
$entity_id = $form_state
->getValue('content_entity');
// DB entity to YAML
$entity = $this->entityTypeManager
->getStorage($entity_type)
->load($entity_id);
// Generate the YAML file.
$serializer_context = [];
$exported_entity = $this->contentExporter
->exportEntity($entity, $serializer_context);
// Create the name
$name = $entity_type . "." . $entity
->bundle() . "." . $entity
->uuid();
// Return form values
$form['export']['#value'] = $exported_entity;
$form['export']['#description'] = $this
->t('Filename: %name', [
'%name' => $name . '.yml',
]);
return $form['export'];
}