You are here

public function WorkflowController::entryList in Forms Steps 8

Render a list of entries in the database.

File

src/Controller/WorkflowController.php, line 45

Class

WorkflowController
Class WorkflowController.

Namespace

Drupal\forms_steps\Controller

Code

public function entryList() {
  $content = [];
  $content['message'] = [
    '#markup' => $this
      ->t('List of all workflow instances.'),
  ];
  $rows = [];
  $headers = [
    $this
      ->t('Id'),
    $this
      ->t('instance_id'),
    $this
      ->t('Entity type'),
    $this
      ->t('Bundle'),
    $this
      ->t('Form mode'),
  ];
  $entries = $this->repository
    ->load();
  foreach ($entries as $entry) {

    // Sanitize each entry.
    $rows[] = array_map('Drupal\\Component\\Utility\\Html::escape', (array) $entry);
  }
  $content['table'] = [
    '#type' => 'table',
    '#header' => $headers,
    '#rows' => $rows,
    '#empty' => $this
      ->t('No entries available.'),
  ];

  // Don't cache this page.
  $content['#cache']['max-age'] = 0;
  return $content;
}