public function ConvertBundlesForm::submitForm in Convert Bundles 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/ ConvertBundlesForm.php, line 246
Class
- ConvertBundlesForm
- ConvertBundlesForm.
Namespace
Drupal\convert_bundles\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
switch ($this->step) {
case 1:
$form_state
->setRebuild();
$this->entityType = $form_state
->getValues()['convert_entity_type'];
break;
case 2:
$form_state
->setRebuild();
$this->fromType = array_filter($form_state
->getValues()['convert_bundles_from']);
if (empty($this->entities)) {
$this->entities = ConvertBundles::getEntities($this->entityType, $this->fromType);
}
break;
case 3:
$form_state
->setRebuild();
$this->toType = $form_state
->getValues()['convert_bundles_to'];
break;
case 4:
$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 5:
$this->createNew = $form['create_new']['#value'];
if (!$this->createNew) {
$this->step++;
goto six;
}
$form_state
->setRebuild();
break;
case 6:
$values = $form_state
->getValues()['default_value_input'];
foreach ($values as $key => $value) {
unset($values[$key]['add_more']);
if (isset($value['value'])) {
$values[$key] = $value['value'];
}
}
$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.
six:
$form_state
->setRebuild();
break;
case 7:
if (method_exists($this, 'ConvertBundles')) {
$return_verify = $this
->ConvertBundles();
}
\Drupal::messenger()
->addStatus($return_verify);
$this->routeBuilder
->rebuild();
break;
}
$this->step++;
}