You are here

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

Callback for the Memcache Stats page.

Parameters

string $bin: The bin name.

Return value

array The page output.

1 string reference to 'MemcacheStatisticsController::statsTable'
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 29

Class

MemcacheStatisticsController
Memcache Statistics.

Namespace

Drupal\memcache_admin\Controller

Code

public function statsTable($bin = 'default') {
  $bin = $this
    ->getBinMapping($bin);

  /** @var $memcache \Drupal\memcache\DrupalMemcacheInterface */
  $memcache = \Drupal::service('memcache.factory')
    ->get($bin, TRUE);

  // Instantiate our event.
  $event = new MemcacheStatsEvent($memcache, $bin);

  // Get the event_dispatcher service and dispatch the event.
  $event_dispatcher = \Drupal::service('event_dispatcher');
  $event_dispatcher
    ->dispatch(MemcacheStatsEvent::BUILD_MEMCACHE_STATS, $event);

  // Report the PHP Memcache(d) driver version.
  if ($memcache
    ->getMemcache() instanceof \Memcached) {
    $raw_stats['driver_version'] = $this
      ->t('PECL Driver in Use: Memcached v@version', [
      '@version' => phpversion('Memcached'),
    ]);
  }
  elseif ($memcache
    ->getMemcache() instanceof \Memcache) {
    $raw_stats['driver_version'] = $this
      ->t('PECL Driver in Use: Memcache v@version', [
      '@version' => phpversion('Memcache'),
    ]);
  }

  // Get the event_dispatcher service and dispatch the event.
  $event_dispatcher = \Drupal::service('event_dispatcher');
  $event_dispatcher
    ->dispatch(MemcacheStatsEvent::REPORT_MEMCACHE_STATS, $event);
  $output = [
    '#markup' => '<p>' . $raw_stats['driver_version'],
  ];
  $output[] = $this
    ->statsTablesOutput($bin, $event
    ->getServers(), $event
    ->getReport());
  return $output;
}