public function ContentSync::submitForm in Content Synchronization 8.2
Same name and namespace in other branches
- 8 src/Form/ContentSync.php \Drupal\content_sync\Form\ContentSync::submitForm()
- 3.0.x src/Form/ContentSync.php \Drupal\content_sync\Form\ContentSync::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/ ContentSync.php, line 207
Class
- ContentSync
- Construct the storage changes in a content synchronization form.
Namespace
Drupal\content_sync\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$comparer = $form_state
->get('storage_comparer');
$collections = $comparer
->getAllCollectionNames();
//Set Batch to process the files from the content directory.
//Get the files to be processed
$content_to_sync = [];
$content_to_delete = [];
foreach ($collections as $collection => $collection_name) {
$actions = $comparer
->getChangeList("", $collection_name);
if (!empty($actions['create'])) {
$content_to_sync = array_merge($content_to_sync, $actions['create']);
}
if (!empty($actions['update'])) {
$content_to_sync = array_merge($content_to_sync, $actions['update']);
}
if (!empty($actions['delete'])) {
$content_to_delete = $actions['delete'];
}
}
$serializer_context = [];
$batch = $this
->generateImportBatch($content_to_sync, $content_to_delete, $serializer_context);
batch_set($batch);
}