public function NewsletterForm::save in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Form/NewsletterForm.php \Drupal\simplenews\Form\NewsletterForm::save()
- 3.x src/Form/NewsletterForm.php \Drupal\simplenews\Form\NewsletterForm::save()
Overrides Drupal\Core\Entity\EntityForm::save().
Overrides EntityForm::save
File
- src/
Form/ NewsletterForm.php, line 198
Class
- NewsletterForm
- Base form for category edit forms.
Namespace
Drupal\simplenews\FormCode
public function save(array $form, FormStateInterface $form_state) {
$newsletter = $this->entity;
$status = $newsletter
->save();
$edit_link = \Drupal::linkGenerator()
->generate($this
->t('Edit'), $this->entity
->toUrl());
if ($status == SAVED_UPDATED) {
$this
->messenger()
->addMessage(t('Newsletter %label has been updated.', array(
'%label' => $newsletter
->label(),
)));
\Drupal::logger('simplenews')
->notice('Newsletter %label has been updated.', array(
'%label' => $newsletter
->label(),
'link' => $edit_link,
));
}
else {
$this
->messenger()
->addMessage(t('Newsletter %label has been added.', array(
'%label' => $newsletter
->label(),
)));
\Drupal::logger('simplenews')
->notice('Newsletter %label has been added.', array(
'%label' => $newsletter
->label(),
'link' => $edit_link,
));
}
$form_state
->setRedirect('simplenews.newsletter_list');
}