You are here

public function YamlFormSubmissionController::index in YAML Form 8

Returns a form submission in a specified format type.

Parameters

\Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission: A form submission.

string $type: The format type.

Return value

array A render array representing a form submission in a specified format type.

2 string references to 'YamlFormSubmissionController::index'
yamlform.routing.yml in ./yamlform.routing.yml
yamlform.routing.yml
yamlform_node.routing.yml in modules/yamlform_node/yamlform_node.routing.yml
modules/yamlform_node/yamlform_node.routing.yml

File

src/Controller/YamlFormSubmissionController.php, line 57

Class

YamlFormSubmissionController
Provides route responses for form submissions.

Namespace

Drupal\yamlform\Controller

Code

public function index(YamlFormSubmissionInterface $yamlform_submission, $type) {
  if ($type == 'default') {
    $type = 'html';
  }
  $build = [];
  $source_entity = $this->requestHandler
    ->getCurrentSourceEntity('yamlform_submission');

  // Navigation.
  $build['navigation'] = [
    '#theme' => 'yamlform_submission_navigation',
    '#yamlform_submission' => $yamlform_submission,
  ];

  // Information.
  $build['information'] = [
    '#theme' => 'yamlform_submission_information',
    '#yamlform_submission' => $yamlform_submission,
    '#source_entity' => $source_entity,
  ];

  // Submission.
  $build['submission'] = [
    '#theme' => 'yamlform_submission_' . $type,
    '#yamlform_submission' => $yamlform_submission,
    '#source_entity' => $source_entity,
  ];

  // Wrap plain text and YAML in CodeMirror view widget.
  if (in_array($type, [
    'text',
    'yaml',
  ])) {
    $build['submission'] = [
      '#theme' => 'yamlform_codemirror',
      '#code' => $build['submission'],
      '#type' => $type,
    ];
  }
  $build['#attached']['library'][] = 'yamlform/yamlform.admin';
  return $build;
}