You are here

public function RedisProfilerStorage::find in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Profiler/RedisProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\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:

int|null $start The start date to search from:

int|null $end The end date to search to:

Return value

array An array of tokens

Overrides ProfilerStorageInterface::find

File

vendor/symfony/http-kernel/Profiler/RedisProfilerStorage.php, line 54

Class

RedisProfilerStorage
RedisProfilerStorage stores profiling information in Redis.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

public function find($ip, $url, $limit, $method, $start = null, $end = null) {
  $indexName = $this
    ->getIndexName();
  if (!($indexContent = $this
    ->getValue($indexName, self::REDIS_SERIALIZER_NONE))) {
    return array();
  }
  $profileList = array_reverse(explode("\n", $indexContent));
  $result = array();
  foreach ($profileList as $item) {
    if ($limit === 0) {
      break;
    }
    if ($item == '') {
      continue;
    }
    $values = explode("\t", $item, 7);
    list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = $values;
    $statusCode = isset($values[6]) ? $values[6] : null;
    $itemTime = (int) $itemTime;
    if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) {
      continue;
    }
    if (!empty($start) && $itemTime < $start) {
      continue;
    }
    if (!empty($end) && $itemTime > $end) {
      continue;
    }
    $result[] = array(
      'token' => $itemToken,
      'ip' => $itemIp,
      'method' => $itemMethod,
      'url' => $itemUrl,
      'time' => $itemTime,
      'parent' => $itemParent,
      'status_code' => $statusCode,
    );
    --$limit;
  }
  return $result;
}