You are here

public function ConfirmMultiForm::buildForm in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Form/ConfirmMultiForm.php \Drupal\simplenews\Form\ConfirmMultiForm::buildForm()
  2. 3.x src/Form/ConfirmMultiForm.php \Drupal\simplenews\Form\ConfirmMultiForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfirmFormBase::buildForm

File

src/Form/ConfirmMultiForm.php, line 46

Class

ConfirmMultiForm
Implements a multi confirmation form for simplenews subscriptions.

Namespace

Drupal\simplenews\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, SubscriberInterface $subscriber = NULL) {
  $form = parent::buildForm($form, $form_state);
  $form['question'] = array(
    '#markup' => '<p>' . t('Are you sure you want to confirm the following subscription changes for %user?', array(
      '%user' => simplenews_mask_mail($subscriber
        ->getMail()),
    )) . "<p>\n",
  );

  /** @var \Drupal\simplenews\Subscription\SubscriptionManagerInterface $subscription_manager */
  $subscription_manager = \Drupal::service('simplenews.subscription_manager');
  $form['changes'] = array(
    '#theme' => 'item_list',
    '#items' => $subscription_manager
      ->getChangesList($subscriber),
  );
  $form['subscriber'] = array(
    '#type' => 'value',
    '#value' => $subscriber,
  );
  return $form;
}