You are here

public function UloginController::uloginReport in uLogin (advanced version) 8

Returns report.

Return value

array Report table.

1 string reference to 'UloginController::uloginReport'
ulogin.routing.yml in ./ulogin.routing.yml
ulogin.routing.yml

File

src/Controller/UloginController.php, line 25

Class

UloginController
Controller routines for user routes.

Namespace

Drupal\ulogin\Controller

Code

public function uloginReport() {
  $providers = UloginHelper::providersList();
  $header = [
    $this
      ->t('Authentication provider'),
    $this
      ->t('Users count'),
  ];
  $rows = [];
  $query = \Drupal::database()
    ->select('ulogin_identity', 'ul_id');
  $query
    ->addField('ul_id', 'network', 'network');
  $query
    ->addExpression('COUNT(ulogin_uid)', 'count');
  $query
    ->groupBy('network');
  $results = $query
    ->execute()
    ->fetchAllAssoc('network', \PDO::FETCH_ASSOC);
  foreach ($results as $result) {
    $rows[] = [
      $providers[$result['network']],
      $result['count'],
    ];
  }
  $build = [];
  $build['report'] = [
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  ];
  return $build;
}