You are here

public function InviteList::view in Invite 8

Returns the active user list output.

Return value

array A renderable array.

1 string reference to 'InviteList::view'
invite.routing.yml in ./invite.routing.yml
invite.routing.yml

File

src/Controller/InviteList.php, line 61

Class

InviteList
Active user list controller.

Namespace

Drupal\invite\Controller

Code

public function view() {
  $header = [
    [
      'data' => $this
        ->t('Status'),
    ],
    [
      'data' => $this
        ->t('Sender'),
    ],
    [
      'data' => $this
        ->t('E-mail'),
    ],
    [
      'data' => $this
        ->t('Operations'),
    ],
  ];
  $query = $this->database
    ->select('invite', 'i');
  $query
    ->fields('ufd', [
    'mail',
  ]);
  $query
    ->fields('i', [
    'id',
    'status',
  ]);
  $query
    ->fields('ie', [
    'field_invite_email_address_value',
  ]);
  $query
    ->leftJoin('users', 'u', 'i.user_id = u.uid');
  $query
    ->leftJoin('users_field_data', 'ufd', 'u.uid = ufd.uid');
  $query
    ->leftJoin('invite__field_invite_email_address', 'ie', 'i.id = ie.entity_id');
  $query
    ->orderBy('i.id', 'desc');
  $query = $query
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender');
  $query
    ->limit(20);
  $result = $query
    ->execute();
  $rows = [];
  foreach ($result as $row) {
    $operations = [
      '#type' => 'operations',
      '#links' => $this
        ->getOperations($row->id),
      '#attributes' => [],
    ];
    $rows[] = [
      'data' => [
        'status' => $this->inviteStatus[$row->status],
        'mail' => $row->mail,
        'field_invite_email_address_value' => $row->field_invite_email_address_value,
        'operations' => render($operations),
      ],
    ];
  }
  $output['table'] = [
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  ];
  $output['pager'] = [
    '#type' => 'pager',
  ];
  return $output;
}