public function ConvertNodesForm::submitForm in Convert Nodes 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
- src/
Form/ ConvertNodesForm.php, line 160
Class
- ConvertNodesForm
- ConvertNodesForm.
Namespace
Drupal\convert_nodes\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
switch ($this->step) {
case 1:
$form_state
->setRebuild();
$this->fromType = $form['convert_nodes_content_type_from']['#value'];
$this->toType = $form['convert_nodes_content_type_to']['#value'];
break;
case 2:
$form_state
->setRebuild();
$data_to_process = array_diff_key($form_state
->getValues(), array_flip([
'op',
'submit',
'form_id',
'form_build_id',
'form_token',
]));
$this->userInput = $data_to_process;
break;
case 3:
$this->createNew = $form['create_new']['#value'];
if (!$this->createNew) {
$this->step++;
goto five;
}
$form_state
->setRebuild();
break;
case 4:
$values = $form_state
->getValues()['default_value_input'];
foreach ($values as $key => $value) {
unset($values[$key]['add_more']);
}
$data_to_process = array_diff_key($values, array_flip([
'op',
'submit',
'form_id',
'form_build_id',
'form_token',
]));
$this->userInput = array_merge($this->userInput, $data_to_process);
// Used also for goto.
five:
$form_state
->setRebuild();
break;
case 5:
if (method_exists($this, 'convertNodes')) {
$return_verify = $this
->convertNodes();
}
$this
->messenger()
->addStatus($return_verify);
$this->routeBuilder
->rebuild();
break;
}
$this->step++;
}