You are here

public function MemcacheStatisticsController::statsTableRaw in Memcache API and Integration 8.2

Callback for the Memcache Stats page.

Parameters

string $cluster: The Memcache cluster name.

string $server: The Memcache server name.

string $type: The type of statistics to retrieve when using the Memcache extension.

Return value

string The page output.

1 string reference to 'MemcacheStatisticsController::statsTableRaw'
memcache_admin.routing.yml in memcache_admin/memcache_admin.routing.yml
memcache_admin/memcache_admin.routing.yml

File

memcache_admin/src/Controller/MemcacheStatisticsController.php, line 72

Class

MemcacheStatisticsController
Memcache Statistics.

Namespace

Drupal\memcache_admin\Controller

Code

public function statsTableRaw($cluster, $server, $type = 'default') {
  $cluster = $this
    ->binMapping($cluster);
  $server = str_replace('!', '/', $server);
  $slab = \Drupal::routeMatch()
    ->getParameter('slab');
  $memcache = \Drupal::service('memcache.factory')
    ->get($cluster, TRUE);
  if ($type == 'slabs' && !empty($slab)) {
    $stats = $memcache
      ->stats($cluster, $slab, FALSE);
  }
  else {
    $stats = $memcache
      ->stats($cluster, $type, FALSE);
  }

  // @codingStandardsIgnoreStart
  // @todo - breadcrumb
  // $breadcrumbs = [
  //   l(t('Home'), NULL),
  //   l(t('Administer'), 'admin'),
  //   l(t('Reports'), 'admin/reports'),
  //   l(t('Memcache'), 'admin/reports/memcache'),
  //   l(t($bin), "admin/reports/memcache/$bin"),
  // ];
  // if ($type == 'slabs' && arg(6) == 'cachedump' && user_access('access slab cachedump')) {
  //   $breadcrumbs[] = l($server, "admin/reports/memcache/$bin/$server");
  //   $breadcrumbs[] = l(t('slabs'), "admin/reports/memcache/$bin/$server/$type");
  // }
  // drupal_set_breadcrumb($breadcrumbs);
  // @codingStandardsIgnoreEnd
  if (isset($stats[$cluster][$server]) && is_array($stats[$cluster][$server]) && count($stats[$cluster][$server])) {
    $output = $this
      ->statsTablesRawOutput($cluster, $server, $stats[$cluster][$server], $type);
  }
  elseif ($type == 'slabs' && is_array($stats[$cluster]) && count($stats[$cluster])) {
    $output = $this
      ->statsTablesRawOutput($cluster, $server, $stats[$cluster], $type);
  }
  else {
    $output = $this
      ->statsTablesRawOutput($cluster, $server, [], $type);
    $this
      ->messenger()
      ->addMessage($this
      ->t('No @type statistics for this bin.', [
      '@type' => $type,
    ]));
  }
  return $output;
}