You are here

protected function ParserConfigurationForm::buildParser in Markdown 8.2

Builds the parser form elements.

Parameters

array $element: An element in a render array.

\Drupal\markdown\Form\SubformStateInterface $form_state: The form state.

Return value

array The $element passed, modified to include the parser element.

1 call to ParserConfigurationForm::buildParser()
ParserConfigurationForm::processSubform in src/Form/ParserConfigurationForm.php
Process callback for constructing markdown settings for a parser.

File

src/Form/ParserConfigurationForm.php, line 270

Class

ParserConfigurationForm
Form for modifying parser configuration.

Namespace

Drupal\markdown\Form

Code

protected function buildParser(array $element, SubformStateInterface $form_state) {
  $parser = $this
    ->getParser();
  $parserId = $parser
    ->getPluginId();
  $markdownGroup = $form_state
    ->get('markdownGroup');
  $markdownParents = $form_state
    ->get('markdownSubformParents');
  $element['parser'] = [
    '#weight' => -20,
    '#type' => 'details',
    '#title' => $this
      ->t('Parser'),
    '#tree' => TRUE,
    '#parents' => $markdownParents,
    '#group' => $markdownGroup,
  ];
  $parserElement =& $element['parser'];
  $parserSubform = SubformState::createForSubform($parserElement, $element, $form_state);
  $parserElement['id'] = static::createElement([
    '#type' => 'hidden',
    '#default_value' => $parserId,
    '#attributes' => [
      'data' => [
        'markdownSummary' => 'parser',
        'markdownSummaryValue' => $parser
          ->getLabel(),
        'markdownId' => $parserId,
      ],
    ],
  ]);

  // Build render strategy.
  $parserElement = $this
    ->buildRenderStrategy($parser, $parserElement, $parserSubform);

  // Build parser settings.
  $parserElement = $this
    ->buildParserSettings($parser, $parserElement, $parserSubform);

  // Build parser extensions.
  $parserElement = $this
    ->buildParserExtensions($parser, $parserElement, $parserSubform);
  return $element;
}