You are here

public function RenderedSiteSettingsBlock::blockForm in Site Settings and Labels 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/RenderedSiteSettingsBlock.php, line 75

Class

RenderedSiteSettingsBlock
Provides a 'RenderedSiteSettingsBlock' block.

Namespace

Drupal\site_settings\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {

  // Allow selection of a site settings entity type.
  $form['setting'] = [
    '#type' => 'entity_autocomplete',
    '#target_type' => 'site_setting_entity_type',
    '#title' => $this
      ->t('Site setting type'),
    '#weight' => '20',
    '#required' => TRUE,
  ];
  if (isset($this->configuration['setting']) && !empty($this->configuration['setting'])) {
    $setting_entity_type = $this->entityTypeManager
      ->getStorage('site_setting_entity_type')
      ->load($this->configuration['setting']);
    $form['setting']['#default_value'] = $setting_entity_type;
  }
  return $form;
}