Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php namespace Clockwork\Storage;use Clockwork\Request\Request;use Clockwork\Support\Symfony\ProfileTransformer;use Symfony\Component\HttpKernel\Profiler\Profiler;// Storage wrapping Symfony profilerclass SymfonyStorage extends FileStorage{// Symfony profiler instanceprotected $profiler;// Symfony profiler pathprotected $path;// Create a new instance, takes Symfony profiler instance and path as argumentpublic function __construct(Profiler $profiler, $path){$this->profiler = $profiler;$this->path = $path;}// Store request, no-op since this is read-only storage implementationpublic function store(Request $request, $skipIndex = false){return;}// Cleanup old requests, no-op since this is read-only storage implementationpublic function cleanup($force = false){return;}protected function loadRequest($token){return ($profile = $this->profiler->loadProfile($token)) ? (new ProfileTransformer)->transform($profile) : null;}// Open index file, optionally move file pointer to the endprotected function openIndex($position = 'start', $lock = null, $force = null){$this->indexHandle = fopen("{$this->path}/index.csv", 'r');if ($position == 'end') fseek($this->indexHandle, 0, SEEK_END);}protected function makeRequestFromIndex($record){return new Request(array_combine([ 'id', 'ip', 'method', 'uri', 'time', 'parent', 'responseStatus' ], $record));}}