You are here

public function GroupContentTypeDeleteForm::buildForm in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/Form/GroupContentTypeDeleteForm.php \Drupal\group\Entity\Form\GroupContentTypeDeleteForm::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 EntityDeleteForm::buildForm

File

src/Entity/Form/GroupContentTypeDeleteForm.php, line 61

Class

GroupContentTypeDeleteForm
Provides a form for group content type deletion.

Namespace

Drupal\group\Entity\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $entity_count = $this->entityTypeManager
    ->getStorage('group_content')
    ->getQuery()
    ->accessCheck(FALSE)
    ->condition('type', $this->entity
    ->id())
    ->count()
    ->execute();
  if (!empty($entity_count)) {
    $form['#title'] = $this
      ->getQuestion();
    $form['description'] = [
      '#markup' => '<p>' . $this
        ->t('You can not uninstall this content plugin until you have removed all of the content that uses it.') . '</p>',
    ];
    return $form;
  }
  return parent::buildForm($form, $form_state);
}