You are here

public function PrivateMessageInboxBlock::blockForm in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Block/PrivateMessageInboxBlock.php \Drupal\private_message\Plugin\Block\PrivateMessageInboxBlock::blockForm()

Returns the configuration form elements specific to this block plugin.

Blocks that need to add form elements to the normal block configuration form should implement this method.

Parameters

array $form: The form definition array for the block configuration form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The renderable form array representing the entire configuration form.

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/PrivateMessageInboxBlock.php, line 193

Class

PrivateMessageInboxBlock
Provides the private message inbox block.

Namespace

Drupal\private_message\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);
  $config = $this
    ->getConfiguration();
  $form['thread_count'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Number of threads to show'),
    '#description' => $this
      ->t('The number of threads to be shown in the block'),
    '#default_value' => $config['thread_count'],
    '#min' => 1,
  ];
  $form['ajax_load_count'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Number of threads to load with ajax'),
    '#description' => $this
      ->t('The number of threads to be loaded when the load previous link is clicked'),
    '#default_value' => $config['ajax_load_count'],
    '#min' => 1,
  ];
  $form['ajax_refresh_rate'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Ajax refresh rate'),
    '#default_value' => $config['ajax_refresh_rate'],
    '#min' => 0,
    '#description' => $this
      ->t('The number of seconds after which the inbox should refresh itself. Setting this to a low number will result in more requests to the server, adding overhead and bandwidth. Setting this number to zero will disable ajax refresh, and the inbox will only updated if/when the page is refreshed.'),
  ];
  return $form;
}