protected function VisitorsBlock::_showTotalVisitors in Visitors 8.2
Display total visitors count to visitors block.
1 call to VisitorsBlock::_showTotalVisitors()
- VisitorsBlock::build in src/
Plugin/ Block/ VisitorsBlock.php - Builds and returns the renderable array for this block plugin.
File
- src/
Plugin/ Block/ VisitorsBlock.php, line 51 - Contains \Drupal\visitors\Plugin\Block\VisitorsBlock.
Class
- VisitorsBlock
- Provides a 'Visitors' block.
Namespace
Drupal\visitors\Plugin\BlockCode
protected function _showTotalVisitors() {
if ($this->config
->get('show_total_visitors')) {
$query = \Drupal::database()
->select('visitors');
$query
->addExpression('COUNT(*)');
$count = $query
->execute()
->fetchField() + $this->config
->get('start_count_total_visitors');
$this->items[] = t('Total Visitors: %visitors', array(
'%visitors' => $count,
));
}
}