function CommentTypeForm::save
Same name in other branches
- 9 core/modules/comment/src/CommentTypeForm.php \Drupal\comment\CommentTypeForm::save()
- 8.9.x core/modules/comment/src/CommentTypeForm.php \Drupal\comment\CommentTypeForm::save()
- 10 core/modules/comment/src/CommentTypeForm.php \Drupal\comment\CommentTypeForm::save()
Overrides EntityForm::save
File
-
core/
modules/ comment/ src/ CommentTypeForm.php, line 182
Class
- CommentTypeForm
- Base form handler for comment type edit forms.
Namespace
Drupal\commentCode
public function save(array $form, FormStateInterface $form_state) {
$comment_type = $this->entity;
$status = $comment_type->save();
$edit_link = $this->entity
->toLink($this->t('Edit'), 'edit-form')
->toString();
if ($status == SAVED_UPDATED) {
$this->messenger()
->addStatus($this->t('Comment type %label has been updated.', [
'%label' => $comment_type->label(),
]));
$this->logger
->notice('Comment type %label has been updated.', [
'%label' => $comment_type->label(),
'link' => $edit_link,
]);
}
else {
$this->commentManager
->addBodyField($comment_type->id());
$this->messenger()
->addStatus($this->t('Comment type %label has been added.', [
'%label' => $comment_type->label(),
]));
$this->logger
->notice('Comment type %label has been added.', [
'%label' => $comment_type->label(),
'link' => $edit_link,
]);
}
$form_state->setRedirectUrl($comment_type->toUrl('collection'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.