You are here

protected function OverrideWebformVariant::debug in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformVariant/OverrideWebformVariant.php \Drupal\webform\Plugin\WebformVariant\OverrideWebformVariant::debug()

Display debugging information.

1 call to OverrideWebformVariant::debug()
OverrideWebformVariant::applyVariant in src/Plugin/WebformVariant/OverrideWebformVariant.php
Apply variant to the webform.

File

src/Plugin/WebformVariant/OverrideWebformVariant.php, line 255

Class

OverrideWebformVariant
Webform override variant.

Namespace

Drupal\webform\Plugin\WebformVariant

Code

protected function debug() {
  if (empty($this->configuration['debug'])) {
    return;
  }
  $build = [
    '#type' => 'details',
    '#title' => $this
      ->t('Debug: Override: @title', [
      '@title' => $this
        ->label(),
    ]),
  ];

  // Notes.
  if ($notes = $this
    ->getNotes()) {
    $build['notes'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Notes'),
      'notes' => WebformHtmlEditor::checkMarkup($notes),
    ];
  }

  // Settings.
  if ($this->configuration['settings']) {
    $build['settings'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Settings'),
      'yaml' => [
        '#theme' => 'webform_codemirror',
        '#type' => 'yaml',
        '#code' => WebformYaml::encode($this->configuration['settings']),
      ],
    ];
  }

  // Elements.
  if ($this->configuration['elements']) {
    $build['elements'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Elements'),
      'yaml' => [
        '#theme' => 'webform_codemirror',
        '#type' => 'yaml',
        '#code' => $this->configuration['elements'],
      ],
    ];
  }

  // Handlers.
  if ($this->configuration['handlers']) {
    $build['handlers'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Handlers'),
      'yaml' => [
        '#theme' => 'webform_codemirror',
        '#type' => 'yaml',
        '#code' => WebformYaml::encode($this->configuration['handlers']),
      ],
    ];
  }
  $this
    ->messenger()
    ->addWarning(\Drupal::service('renderer')
    ->renderPlain($build));
}