public function CKEditorEntityLinkDialog::submitForm in CKEditor Entity Link 8
Return value
\Drupal\Core\Ajax\AjaxResponse
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityMalformedException
Overrides FormInterface::submitForm
File
- src/
Form/ CKEditorEntityLinkDialog.php, line 161
Class
- CKEditorEntityLinkDialog
- Provides a link dialog for text editors.
Namespace
Drupal\ckeditor_entity_link\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
if ($form_state
->getErrors()) {
unset($form['#prefix'], $form['#suffix']);
$form['status_messages'] = [
'#type' => 'status_messages',
'#weight' => -10,
];
$response
->addCommand(new HtmlCommand('#ckeditor-entity-link-dialog-form', $form));
}
else {
$entity = $this->entityTypeManager
->getStorage($form_state
->getValue('entity_type'))
->load($form_state
->getValue('entity_id'));
// Get the entity translation from context.
$entity = $this->entityRepository
->getTranslationFromContext($entity);
$values = [
'attributes' => [
'href' => $this
->getUrl($entity),
] + $form_state
->getValue('attributes', []),
];
$response
->addCommand(new EditorDialogSave($values));
$response
->addCommand(new CloseModalDialogCommand());
}
return $response;
}