You are here

public function SocialSharePrivacySettingsForm::buildForm in Share Message 8

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 ConfigFormBase::buildForm

File

src/Form/SocialSharePrivacySettingsForm.php, line 34

Class

SocialSharePrivacySettingsForm
Defines a form that configures Social Share Privacy settings.

Namespace

Drupal\sharemessage\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
  $form = parent::buildForm($form, $form_state);
  $social_share_privacy_config = $this
    ->config('sharemessage.socialshareprivacy');
  $form['services'] = [
    '#title' => $this
      ->t('Default visible services'),
    '#type' => 'select',
    '#multiple' => TRUE,
    '#options' => SocialSharePrivacy::allServices(),
    '#default_value' => $social_share_privacy_config
      ->get('services'),
    '#size' => 11,
  ];
  $form['facebook_action'] = [
    '#title' => $this
      ->t('Choose facebook action'),
    '#type' => 'radios',
    '#default_value' => $social_share_privacy_config
      ->get('facebook_action') ?: 'like',
    '#options' => [
      'like' => $this
        ->t('Like'),
      'recommend' => $this
        ->t('Recommend'),
    ],
  ];
  $form['disqus_shortname'] = [
    '#title' => $this
      ->t('Disqus shortname'),
    '#type' => 'textfield',
    '#description' => $this
      ->t('You can get shortname from <a href=":url">Disqus</a>.', [
      ':url' => 'https://disqus.com/',
    ]),
    '#default_value' => $social_share_privacy_config
      ->get('disqus_shortname'),
  ];
  $form['flattr_uid'] = [
    '#title' => $this
      ->t('Flattr user id'),
    '#type' => 'textfield',
    '#description' => $this
      ->t('You can get user id from <a href=":url">Flattr</a>.', [
      ':url' => 'https://flattr.com/',
    ]),
    '#default_value' => $social_share_privacy_config
      ->get('flattr_uid'),
  ];
  return $form;
}