public function RedisProfilerStorage::find

Finds profiler tokens for the given criteria.

Parameters

string $ip The IP:

string $url The URL:

string $limit The maximum number of tokens to return:

string $method The request method:

Return value

array An array of tokens

Overrides ProfilerStorageInterface::find

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php, line 55

Class

RedisProfilerStorage
RedisProfilerStorage stores profiling information in Redis.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

public function find($ip, $url, $limit, $method) {
  $indexName = $this
    ->getIndexName();
  if (!($indexContent = $this
    ->getValue($indexName, self::REDIS_SERIALIZER_NONE))) {
    return array();
  }
  $profileList = explode("\n", $indexContent);
  $result = array();
  foreach ($profileList as $item) {
    if ($limit === 0) {
      break;
    }
    if ($item == '') {
      continue;
    }
    list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = explode("\t", $item, 6);
    if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) {
      continue;
    }
    $result[$itemToken] = array(
      'token' => $itemToken,
      'ip' => $itemIp,
      'method' => $itemMethod,
      'url' => $itemUrl,
      'time' => $itemTime,
      'parent' => $itemParent,
    );
    --$limit;
  }
  usort($result, function ($a, $b) {
    if ($a['time'] === $b['time']) {
      return 0;
    }
    return $a['time'] > $b['time'] ? -1 : 1;
  });
  return $result;
}