public function SolrFieldTypeForm::save in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 src/Form/SolrFieldTypeForm.php \Drupal\search_api_solr\Form\SolrFieldTypeForm::save()
- 8.2 src/Form/SolrFieldTypeForm.php \Drupal\search_api_solr\Form\SolrFieldTypeForm::save()
Throws
\Drupal\Core\Entity\EntityMalformedException
\Drupal\Core\Entity\EntityStorageException
Overrides EntityForm::save
File
- src/
Form/ SolrFieldTypeForm.php, line 119
Class
- SolrFieldTypeForm
- Class SolrFieldTypeForm.
Namespace
Drupal\search_api_solr\FormCode
public function save(array $form, FormStateInterface $form_state) {
/** @var \Drupal\search_api_solr\SolrFieldTypeInterface $solr_field_type */
$solr_field_type = $this->entity;
$solr_field_type
->setFieldTypeAsJson($form_state
->getValue('field_type'));
$solr_field_type
->setTextFiles($form_state
->getValue('text_files') ?? []);
$status = $solr_field_type
->save();
if ($status) {
$this->messenger
->addStatus($this
->t('Saved the %label Solr Field Type.', [
'%label' => $solr_field_type
->label(),
]));
}
else {
$this->messenger
->addWarning($this
->t('The %label Solr Field Type was not saved.', [
'%label' => $solr_field_type
->label(),
]));
}
$form_state
->setRedirectUrl($solr_field_type
->toUrl('collection'));
}