public function ContentExportForm::submitForm in Content Synchronization 3.0.x
Same name and namespace in other branches
- 8.2 src/Form/ContentExportForm.php \Drupal\content_sync\Form\ContentExportForm::submitForm()
- 8 src/Form/ContentExportForm.php \Drupal\content_sync\Form\ContentExportForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ ContentExportForm.php, line 77
Class
- ContentExportForm
- Defines the content export form.
Namespace
Drupal\content_sync\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Delete the content tar file in case an older version exist.
$this->fileSystem
->delete($this
->getTempFile());
//Set batch operations by entity type/bundle
$entities_list = [];
$entity_type_definitions = $this->entityTypeManager
->getDefinitions();
foreach ($entity_type_definitions as $entity_type => $definition) {
$reflection = new \ReflectionClass($definition
->getClass());
if ($reflection
->implementsInterface(ContentEntityInterface::class)) {
$entities = $this->entityTypeManager
->getStorage($entity_type)
->getQuery()
->execute();
foreach ($entities as $entity_id) {
$entities_list[] = [
'entity_type' => $entity_type,
'entity_id' => $entity_id,
];
}
}
}
if (!empty($entities_list)) {
$serializer_context['export_type'] = 'tar';
$serializer_context['include_files'] = 'folder';
$batch = $this
->generateExportBatch($entities_list, $serializer_context);
batch_set($batch);
}
}