You are here

private function ContactPopupBlock::listContactForms in Contact Form Popup 8

Return value

array $options An array of available contact forms.

1 call to ContactPopupBlock::listContactForms()
ContactPopupBlock::blockForm in src/Plugin/Block/ContactPopupBlock.php

File

src/Plugin/Block/ContactPopupBlock.php, line 207

Class

ContactPopupBlock
Provides a 'ContactPopupBlock' block.

Namespace

Drupal\contact_poup\Plugin\Block

Code

private function listContactForms() {
  $options = [];
  $storage_contact_form = $this->entityTypeManager
    ->getStorage('contact_form');
  $list_contact_form = $storage_contact_form
    ->getQuery()
    ->execute();
  foreach ($list_contact_form as $contact_form) {

    /** @var \Drupal\contact\Entity\ContactForm $contact */
    $contact = $storage_contact_form
      ->load($contact_form);
    $options[$contact
      ->id()] = $contact
      ->label();
  }
  return $options;
}