You are here

public function LingotekManagementRelatedEntitiesForm::buildForm in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  2. 4.0.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  3. 3.0.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  4. 3.1.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  5. 3.2.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  6. 3.3.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  7. 3.5.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  8. 3.6.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  9. 3.7.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::buildForm()
  10. 3.8.x src/Form/LingotekManagementRelatedEntitiesForm.php \Drupal\lingotek\Form\LingotekManagementRelatedEntitiesForm::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 LingotekManagementFormBase::buildForm

File

src/Form/LingotekManagementRelatedEntitiesForm.php, line 90

Class

LingotekManagementRelatedEntitiesForm
Form for bulk management of related content.

Namespace

Drupal\lingotek\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, ContentEntityInterface $node = NULL) {
  $this->node = $node;
  $form = parent::buildForm($form, $form_state);
  $related = $this->related;
  $depth = $this
    ->getRecursionDepth();
  $form['depth_selection'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => 'form-item-depth-selection',
    ],
    '#weight' => 60,
  ];
  $form['depth_selection']['depth'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Recursion depth:'),
    '#options' => [
      1 => 1,
      2 => 2,
      3 => 3,
      4 => 4,
      5 => 5,
    ],
    '#default_value' => $depth,
  ];
  $form['depth_selection']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Apply'),
    '#submit' => [
      [
        $this,
        'recursionDepthCallback',
      ],
    ],
  ];
  $relatedRows = [];
  if (!empty($related)) {

    // Generate the rows based on those entities.
    $relatedRows = $this
      ->getRows($related);
  }
  $form['related'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Embedded content references'),
    '#description' => $this
      ->t('These entities are included in the parent document, but listed here for reference. It is not recommended to operate on this data, as its contents will be already translated with the embedding document.'),
    '#weight' => 100,
  ];
  $form['related']['table'] = [
    '#header' => $this
      ->getHeaders(),
    '#rows' => $relatedRows,
    '#empty' => $this
      ->t('No embedded content available'),
    '#type' => 'table',
    '#weight' => 100,
  ];
  return $form;
}