You are here

public function WebformShareController::test in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_share/src/Controller/WebformShareController.php \Drupal\webform_share\Controller\WebformShareController::test()

Returns a test of a webform to be shared.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request object.

Return value

array A render array containing a review of the webform to be shared.

1 string reference to 'WebformShareController::test'
webform_share.routing.yml in modules/webform_share/webform_share.routing.yml
modules/webform_share/webform_share.routing.yml

File

modules/webform_share/src/Controller/WebformShareController.php, line 211

Class

WebformShareController
Provides route responses for webform share page, script, and embed.

Namespace

Drupal\webform_share\Controller

Code

public function test(Request $request) {
  $webform = $this->requestHandler
    ->getCurrentWebform();
  $source_entity = $this->requestHandler
    ->getCurrentSourceEntity([
    'webform',
  ]);
  $build = [];
  $build['message'] = [
    '#type' => 'webform_message',
    '#message_message' => $this->messageManager
      ->get(WebformMessageManagerInterface::SUBMISSION_TEST),
    '#message_type' => 'warning',
    '#message_close' => TRUE,
    '#message_storage' => WebformMessage::STORAGE_SESSION,
  ];
  $build['test'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'webform-share-iframe-container',
      ],
    ],
  ];
  $build['test']['iframe'] = [
    '#type' => 'webform_share_iframe',
    '#webform' => $webform,
    '#source_entity' => $source_entity,
    '#test' => TRUE,
    '#javascript' => TRUE,
    '#options' => [
      'log' => TRUE,
    ],
    '#query' => $request->query
      ->all(),
  ];
  $build['#attached']['library'][] = 'webform_share/webform_share.admin';
  return $build;
}