updated simplenews from 1-beta to 2-beta, translated subscription form

This commit is contained in:
2021-06-08 10:41:18 +02:00
parent 3105ce1e81
commit 30a75e09db
12 changed files with 93 additions and 143 deletions

View File

@@ -163,20 +163,12 @@ class MaterioSimplenewsSubscriptionBlock extends BlockBase implements ContainerF
$form_object = $this->entityTypeManager->getFormObject('simplenews_subscriber', 'materio_block');
$form_object->setUniqueId($this->configuration['unique_id']);
$form_object->setNewsletterIds($this->configuration['newsletters']);
$form_object->message = $this->configuration['message'];
$form_object->message = t($this->configuration['message']);
// Set the entity on the form.
if ($user = \Drupal::currentUser()) {
if ($subscriber = simplenews_subscriber_load_by_uid($user->id())) {
$form_object->setEntity($subscriber);
}
else {
$form_object->setEntity(Subscriber::create()->fillFromAccount($user));
}
}
else {
$form_object->setEntity(Subscriber::create());
}
$user = \Drupal::currentUser();
$form_object->setEntity(Subscriber::loadByUid($user->id(), 'create'));
return $this->formBuilder->getForm($form_object);
}