public function ImportPartialForm::submitForm in Tome 8
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
- modules/
tome_sync/ src/ Form/ ImportPartialForm.php, line 228
Class
- ImportPartialForm
- Contains a form for performing a partial import.
Namespace
Drupal\tome_sync\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->state
->set(ImporterInterface::STATE_KEY_IMPORTING, TRUE);
$batch_builder = (new BatchBuilder())
->setTitle($this
->t('Importing changes...'))
->setFinishCallback([
$this,
'finishCallback',
]);
$change_list = $this->contentHasher
->getChangelist();
foreach ($change_list['deleted'] as $name) {
$batch_builder
->addOperation([
$this,
'deleteContent',
], [
$name,
]);
}
$chunked_names = $this->importer
->getChunkedNames();
foreach ($chunked_names as $i => $chunk) {
foreach ($chunk as $j => $name) {
if (in_array($name, $change_list['modified'], TRUE) || in_array($name, $change_list['added'], TRUE)) {
$batch_builder
->addOperation([
$this,
'importContent',
], [
$name,
]);
}
}
}
$batch_builder
->addOperation([
$this,
'importFiles',
]);
batch_set($batch_builder
->toArray());
}