You are here

protected function BaseParser::renderStrategyDisabledSetting in Markdown 8.2

A description explaining why a setting is disabled due to render strategy.

Parameters

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

Return value

\Drupal\Component\Render\MarkupInterface The rendered description.

1 call to BaseParser::renderStrategyDisabledSetting()
BaseParser::renderStrategyDisabledSettingState in src/Plugin/Markdown/BaseParser.php
Adds a conditional state for a setting element based on render strategy.

File

src/Plugin/Markdown/BaseParser.php, line 261

Class

BaseParser
Base class form Markdown Parser instances.

Namespace

Drupal\markdown\Plugin\Markdown

Code

protected function renderStrategyDisabledSetting(FormStateInterface $form_state) {

  /** @var \Drupal\markdown\Form\SubformStateInterface $form_state */
  $markdownParents = $form_state
    ->get('markdownSubformParents');
  $parents = array_merge($markdownParents, [
    'render_strategy',
    'type',
  ]);
  $selector = ':input[name="' . array_shift($parents) . '[' . implode('][', $parents) . ']"]';

  /** @var \Drupal\markdown\Form\SubformStateInterface $form_state */
  return new FormattableMarkup('@disabled@warning', [
    '@disabled' => $form_state
      ->conditionalElement([
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'form-item--description',
          'is-disabled',
        ],
      ],
      [
        '#markup' => $this
          ->moreInfo($this
          ->t('<strong>NOTE:</strong> This setting is disabled when a render strategy is being used.'), RenderStrategyInterface::DOCUMENTATION_URL),
      ],
    ], 'visible', $selector, [
      '!value' => static::NONE,
    ]),
    '@warning' => $form_state
      ->conditionalElement([
      '#type' => 'container',
      '#theme_wrappers' => [
        'container__markdown_disabled_setting__render_strategy__warning',
      ],
      '#attributes' => [
        'class' => [
          'form-item__error-message',
          'form-item--error-message',
        ],
      ],
      [
        '#markup' => $this
          ->moreInfo($this
          ->t('<strong>WARNING:</strong> This setting does not guarantee protection against malicious JavaScript from being injected. It is recommended to use the "Filter Output" render strategy.'), RenderStrategyInterface::DOCUMENTATION_URL),
      ],
    ], 'visible', $selector, [
      'value' => static::NONE,
    ]),
  ]);
}