You are here

public function FacebookFeedBlock::blockForm in Facebook Feed Block 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/FacebookFeedBlock.php, line 34

Class

FacebookFeedBlock
Provides a 'FacebookFeedBlock' block.

Namespace

Drupal\facebook_feed\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form['feed_settings'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Feed settings'),
    '#weight' => '5',
  ];
  $form['feed_settings']['page_id'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Page ID'),
    '#description' => $this
      ->t('ID of the page'),
    '#default_value' => $this->configuration['page_id'],
    '#maxlength' => 64,
    '#size' => 15,
    '#required' => TRUE,
  ];
  $form['feed_settings']['page_id_info'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('What is my page ID?'),
    '#weight' => '6',
  ];
  $form['feed_settings']['page_id_info']['summary'] = [
    '#markup' => '<p>If you have a Facebook <b>page</b> with a URL like this: <code>https://www.facebook.com/your_page_name</code> then the Page ID is just <b>your_page_name</b>.</p>',
  ];
  $form['feed_settings']['access_token'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('(optional) Access token'),
    '#description' => $this
      ->t('Access token needed to deal with the Facebook API'),
    '#default_value' => $this->configuration['access_token'],
    '#weight' => '7',
  ];
  $form['feed_settings']['access_token_info'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('What is an access token?'),
    '#weight' => '8',
  ];
  $form['feed_settings']['access_token_info']['summary'] = [
    '#markup' => '<p>A Facebook Access Token is not required to use this module, but we recommend it so that you are not reliant on the token built into the module.</p>' . '<p>If you have your own token then you can enter it here.</p>' . '<p>To get your own Access Token you can follow these step-by-step instructions.</p>',
  ];
  $form['feed_settings']['show_socials'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show social media stats'),
    '#description' => $this
      ->t('Whether the number of likes, comments and shares of each post should be shown.'),
    '#default_value' => $this->configuration['show_socials'],
    '#weight' => '9',
  ];
  $form['feed_settings']['limit'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Posts limit'),
    '#description' => $this
      ->t('The maximum number of posts that will be fetched.'),
    '#default_value' => $this->configuration['limit'],
    '#min' => 0,
    '#max' => 100,
    '#step' => 1,
    '#size' => 3,
    '#weight' => '10',
  ];
  return $form;
}