You are here

function LoggerController::pagerInit in MongoDB 8

Initialize the global pager variables for use in a mongodb_watchdog event list.

1 call to LoggerController::pagerInit()
LoggerController::watchdogEvent in src/Logger/LoggerController.php
Display watchdogs entry details in MongoDB.

File

src/Logger/LoggerController.php, line 78
Controller service for the MongoDB Watchdog reports.

Class

LoggerController

Namespace

Drupal\mongodb\Logger

Code

function pagerInit($element, $limit, $total) {
  global $pager_page_array, $pager_total, $pager_total_items;

  // Initialize pager, see pager.inc.
  $page = isset($_GET['page']) ? $_GET['page'] : '';
  $pager_page_array = explode(',', $page);
  if (!isset($pager_page_array[$element])) {
    $pager_page_array[$element] = 0;
  }
  $pager_total_items[$element] = $total;
  $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
  $pager_page_array[$element] = max(0, min((int) $pager_page_array[$element], (int) $pager_total[$element] - 1));
  return isset($pager_page_array[$element]) ? $pager_page_array[$element] : 0;
}