You are here

public function ReviewUserForm::buildForm in User Merge 2.x

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 MultiStepFormBase::buildForm

File

src/Form/ReviewUserForm.php, line 24

Class

ReviewUserForm
Class MergeAccountsForm.

Namespace

Drupal\usermerge\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $retire = $this->multiStepStorage
    ->getRetiredAccount();
  $retain = $this->multiStepStorage
    ->getRetainedAccount();
  $form['data'] = [];
  $form['data']['core'] = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Property'),
      $this
        ->t('Retired account'),
      $this
        ->t('Retained account'),
    ],
  ];
  $row = 1;
  $discarded = [
    'uid' => 'id',
    'uuid' => 'uuid',
    'name' => 'getAccountName',
    'email' => 'getEmail',
  ];
  foreach ($discarded as $property => $method) {
    $form['data']['core'][$row]['property'] = [
      '#markup' => $property,
    ];
    $form['data']['core'][$row]['retire'] = [
      '#markup' => $retire
        ->{$method}(),
    ];
    $form['data']['core'][$row]['retain'] = [
      '#markup' => $retain
        ->{$method}(),
    ];
    $row++;
  }

  // Add submit buttons.
  $form = parent::buildForm($form, $form_state);
  return $form;
}