You are here

public function EmojiExtension::buildConfigurationForm in Markdown 8.2

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form: An associative array containing the initial structure of the plugin form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Return value

array The form structure.

Overrides PluginFormInterface::buildConfigurationForm

File

src/Plugin/Markdown/CommonMark/Extension/EmojiExtension.php, line 95

Class

EmojiExtension
Emoji extension.

Namespace

Drupal\markdown\Plugin\Markdown\CommonMark\Extension

Code

public function buildConfigurationForm(array $element, FormStateInterface $form_state) {

  /** @var \Drupal\markdown\Form\SubformStateInterface $form_state */
  $element += $this
    ->createSettingElement('github_api_token', [
    '#type' => 'textfield',
    '#title' => $this
      ->t('GitHub API Token'),
    '#description' => $this
      ->t('You must <a href=":generate_token" target="_blank">generate a GitHub API token</a> that will be used as the map of available emojis. Note: it does not need any scopes or permissions, it is just used for authentication to avoid rate limiting.', [
      ':generate_token' => 'https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line',
    ]),
  ], $form_state);
  return $element;
}