You are here

public function MergeConfirmForm::buildForm in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/Form/MergeConfirmForm.php \Drupal\bibcite_entity\Form\MergeConfirmForm::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

modules/bibcite_entity/src/Form/MergeConfirmForm.php, line 81

Class

MergeConfirmForm
Confirm merge of bibliographic entities.

Namespace

Drupal\bibcite_entity\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $field_name = NULL) {
  $this->fieldName = $field_name;
  $statistic = $this
    ->getAuthoredReferencesStatistic();
  $form['references'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('This operation will cause changes in these references'),
    'items' => [
      '#markup' => $this
        ->t('No one reference will be changed.'),
    ],
  ];
  if (count($statistic['entities']) > 0) {
    $items = array_map(function (ReferenceInterface $reference) {
      return $reference
        ->label();
    }, $statistic['entities']);
    $form['references']['items'] = [
      '#theme' => 'item_list',
      '#items' => $items,
    ];
  }
  if ($statistic['count'] > 0) {
    $form['references']['count'] = [
      '#markup' => $this
        ->t('and @count more', [
        '@count' => $statistic['count'],
      ]),
    ];
  }
  return parent::buildForm($form, $form_state);
}