public function FileProfilerStorage::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/FileProfilerStorage.php, line 49

Class

FileProfilerStorage
Storage for profiler using files.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

public function find($ip, $url, $limit, $method) {
  $file = $this
    ->getIndexFilename();
  if (!file_exists($file)) {
    return array();
  }
  $file = fopen($file, 'r');
  fseek($file, 0, SEEK_END);
  $result = array();
  while ($limit > 0) {
    $line = $this
      ->readLineFromFile($file);
    if (false === $line) {
      break;
    }
    if ($line === '') {
      continue;
    }
    list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = str_getcsv($line);
    if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) {
      continue;
    }
    $result[$csvToken] = array(
      'token' => $csvToken,
      'ip' => $csvIp,
      'method' => $csvMethod,
      'url' => $csvUrl,
      'time' => $csvTime,
      'parent' => $csvParent,
    );
    --$limit;
  }
  fclose($file);
  return array_values($result);
}