<?php

/**
 * @file
 * Support module for webform that provides handler plugin tests.
 */

use Drupal\webform\WebformSubmissionInterface;

/**
 * Implements hook_theme().
 */
function webform_test_handler_theme() {
  return [
    'webform_handler_test_summary' => [
      'variables' => ['settings' => NULL, 'handler' => []],
    ],
    'webform_handler_test_offcanvas_width' => [
      'variables' => ['settings' => NULL, 'handler' => []],
    ],
  ];
}

/**
 * Implements hook_webform_submissions_pre_purge().
 */
function webform_test_handler_webform_submissions_pre_purge(array &$webform_submissions) {
  array_shift($webform_submissions);
  \Drupal::state()->set('webform_test_purge_hook_pre', array_map(function (WebformSubmissionInterface $submission) {
    return $submission->id();
  }, $webform_submissions));
}

/**
 * Implements hook_webform_submissions_post_purge().
 */
function webform_test_handler_webform_submissions_post_purge(array $webform_submissions) {
  \Drupal::state()->set('webform_test_purge_hook_post', array_map(function (WebformSubmissionInterface $submission) {
    return $submission->id();
  }, $webform_submissions));
}
