WorkflowController.php in Forms Steps 8
File
src/Controller/WorkflowController.php
View source
<?php
namespace Drupal\forms_steps\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\forms_steps\Repository\WorkflowRepository;
use Symfony\Component\DependencyInjection\ContainerInterface;
class WorkflowController extends ControllerBase {
protected $repository;
public static function create(ContainerInterface $container) {
$controller = new static($container
->get('forms_steps.workflow.repository'));
$controller
->setStringTranslation($container
->get('string_translation'));
return $controller;
}
public function __construct(WorkflowRepository $repository) {
$this->repository = $repository;
}
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) {
$rows[] = array_map('Drupal\\Component\\Utility\\Html::escape', (array) $entry);
}
$content['table'] = [
'#type' => 'table',
'#header' => $headers,
'#rows' => $rows,
'#empty' => $this
->t('No entries available.'),
];
$content['#cache']['max-age'] = 0;
return $content;
}
}