public function MailingListSubscribeBlock::blockForm in Mailgun 8
Overrides BlockPluginTrait::blockForm
File
- modules/
mailgun_mailing_lists/ src/ Plugin/ Block/ MailingListSubscribeBlock.php, line 94
Class
- MailingListSubscribeBlock
- Provides a 'MailingListSubscribeBlock' block.
Namespace
Drupal\mailgun_mailing_lists\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
$form = parent::blockForm($form, $form_state);
$config = $this
->getConfiguration();
$lists = $this->mailgunClient
->mailingList()
->pages()
->getLists();
$options = [
'' => $this
->t('- None -'),
];
foreach ((array) $lists as $list) {
$options[$list
->getAddress()] = $list
->getName();
}
$form['mailing_list'] = [
'#type' => 'select',
'#title' => $this
->t('Mailing list'),
'#options' => $options,
'#default_value' => isset($config['mailing_list']) ? $config['mailing_list'] : '',
'#required' => TRUE,
];
return $form;
}