You are here

public function InspectForm::buildForm in Queue UI 8.2

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/InspectForm.php, line 51

Class

InspectForm
Class InspectForm @package Drupal\queue_ui\Form

Namespace

Drupal\queue_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $queue_name = FALSE) {
  if ($queue_ui = $this->queueUIManager
    ->fromQueueName($queue_name)) {
    $rows = [];
    foreach ($queue_ui
      ->getItems($queue_name) as $item) {
      $operations = [];
      foreach ($queue_ui
        ->getOperations() as $op => $title) {
        $operations[] = [
          'title' => $title,
          'url' => Url::fromRoute('queue_ui.inspect.' . $op, [
            'queue_name' => $queue_name,
            'queue_item' => $item->item_id,
          ]),
        ];
      }
      $rows[] = [
        'id' => $item->item_id,
        'expires' => $item->expire ? date(DATE_RSS, $item->expire) : $item->expire,
        'created' => date(DATE_RSS, $item->created),
        'operations' => [
          'data' => [
            '#type' => 'dropbutton',
            '#links' => $operations,
          ],
        ],
      ];
    }
    return [
      'table' => [
        '#type' => 'table',
        '#header' => [
          'id' => $this
            ->t('Item ID'),
          'expires' => $this
            ->t('Expires'),
          'created' => $this
            ->t('Created'),
          'operations' => $this
            ->t('Operations'),
        ],
        '#rows' => $rows,
      ],
      'pager' => [
        '#type' => 'pager',
      ],
    ];
  }
}