You are here

public function AmpSocialShareBlock::blockForm in Accelerated Mobile Pages (AMP) 8.3

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/AmpSocialShareBlock.php, line 55

Class

AmpSocialShareBlock
Provides an AMP Social Share block

Namespace

Drupal\amp\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);

  // Retrieve existing configuration for this block.
  $config = $this
    ->getConfiguration();
  $options = [
    'facebook' => $this
      ->t('Facebook'),
    'twitter' => $this
      ->t('Twitter'),
    'linkedin' => $this
      ->t('LinkedIn'),
    'pinterest' => $this
      ->t('Pinterest'),
    'gplus' => $this
      ->t('G+'),
    'whatsapp' => $this
      ->t('WhatsApp'),
    'tumblr' => $this
      ->t('Tumblr'),
    'email' => $this
      ->t('Email'),
  ];
  $form['providers'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Providers'),
    '#default_value' => isset($config['providers']) ? $config['providers'] : '',
    '#options' => $options,
    '#description' => $this
      ->t('Select the providers you want to allow users to share to.'),
  ];
  $form['app_id'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Facebook provider id'),
    '#description' => $this
      ->t('Required if Facebook is one of the selected items.'),
    '#default_value' => isset($config['app_id']) ? $config['app_id'] : '',
  ];
  return $form;
}