public function ContentSingleImportForm::submitForm in Content Synchronization 8.2
Same name and namespace in other branches
- 8 src/Form/ContentSingleImportForm.php \Drupal\content_sync\Form\ContentSingleImportForm::submitForm()
- 3.0.x src/Form/ContentSingleImportForm.php \Drupal\content_sync\Form\ContentSingleImportForm::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/ ContentSingleImportForm.php, line 94
Class
- ContentSingleImportForm
- Provides a form for importing a single content file.
Namespace
Drupal\content_sync\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$data = $form_state
->getValue('import');
$entity = $this->contentImporter
->importEntity($data);
if ($entity) {
$this
->messenger()
->addStatus($this
->t('Entity @label (@entity_type: @id) imported successfully.', [
'@label' => $entity
->label(),
'@entity_type' => $entity
->getEntityTypeId(),
'@id' => $entity
->id(),
]));
}
else {
$this
->messenger()
->addError($this
->t('Entity could not be imported.'));
}
}