You are here

protected function SettingsWebformHandler::displayDebug in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformHandler/SettingsWebformHandler.php \Drupal\webform\Plugin\WebformHandler\SettingsWebformHandler::displayDebug()

Display debugging information about the current action.

1 call to SettingsWebformHandler::displayDebug()
SettingsWebformHandler::overrideSettings in src/Plugin/WebformHandler/SettingsWebformHandler.php
Alter/override a webform submission webform settings.

File

src/Plugin/WebformHandler/SettingsWebformHandler.php, line 280

Class

SettingsWebformHandler
Webform submission settings handler.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

protected function displayDebug(WebformSubmissionInterface $webform_submission) {
  if (!$this->configuration['debug']) {
    return;
  }
  $settings_definitions = $this
    ->getSettingsDefinitions();
  $settings_override = $this
    ->getSettingsOverride();
  $submission_settings_override = $this
    ->getSubmissionSettingsOverride($webform_submission);

  // Set header.
  $header = [
    'name' => $this
      ->t('Name'),
    'label' => [
      'data' => $this
        ->t('Label'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
    'type' => [
      'data' => $this
        ->t('Type'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
    'setting' => [
      'data' => $this
        ->t('Setting Value'),
      'class' => [
        RESPONSIVE_PRIORITY_MEDIUM,
      ],
    ],
    'submission' => $this
      ->t('Submission Value'),
  ];

  // Set rows.
  $rows = [];
  foreach ($settings_override as $name => $value) {
    $rows[] = [
      'name' => [
        'data' => [
          '#markup' => '<b>' . $name . '</b>',
        ],
      ],
      'label' => $settings_definitions[$name]['label'],
      'type' => $settings_definitions[$name]['type'],
      'setting' => $settings_override[$name],
      'submission' => $submission_settings_override[$name],
    ];
  }
  $build = [
    '#type' => 'details',
    '#title' => $this
      ->t('Debug: Settings: @title', [
      '@title' => $this
        ->label(),
    ]),
    '#open' => TRUE,
  ];
  $build['table'] = [
    '#type' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  ];
  $this
    ->messenger()
    ->addWarning($this->renderer
    ->renderPlain($build));
}