public function UserNewBlock::build

Builds and returns the renderable array for this block plugin.

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockRenderController

File

drupal/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php, line 67
Contains \Drupal\user\Plugin\Block\UserNewBlock.

Class

UserNewBlock
Provides a "Who's new" block.

Namespace

Drupal\user\Plugin\Block

Code

public function build() {

  // Retrieve a list of new users who have accessed the site successfully.
  $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, $this->configuration['whois_new_count'])
    ->fetchAll();
  $build = array(
    '#theme' => 'item_list__user__new',
    '#items' => array(),
  );
  foreach ($items as $account) {
    $build['#items'][] = theme('username', array(
      'account' => $account,
    ));
  }
  return $build;
}