Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
199 lars 1
<?php namespace Clockwork\Storage;
2
 
3
use Clockwork\Request\Request;
4
use Clockwork\Support\Symfony\ProfileTransformer;
5
 
6
use Symfony\Component\HttpKernel\Profiler\Profiler;
7
 
8
// Storage wrapping Symfony profiler
9
class SymfonyStorage extends FileStorage
10
{
11
	// Symfony profiler instance
12
	protected $profiler;
13
 
14
	// Symfony profiler path
15
	protected $path;
16
 
17
	// Create a new instance, takes Symfony profiler instance and path as argument
18
	public function __construct(Profiler $profiler, $path)
19
	{
20
		$this->profiler = $profiler;
21
		$this->path = $path;
22
	}
23
 
24
	// Store request, no-op since this is read-only storage implementation
25
	public function store(Request $request, $skipIndex = false)
26
	{
27
		return;
28
	}
29
 
30
	// Cleanup old requests, no-op since this is read-only storage implementation
31
	public function cleanup($force = false)
32
	{
33
		return;
34
	}
35
 
36
	protected function loadRequest($token)
37
	{
38
		return ($profile = $this->profiler->loadProfile($token)) ? (new ProfileTransformer)->transform($profile) : null;
39
	}
40
 
41
	// Open index file, optionally move file pointer to the end
42
	protected function openIndex($position = 'start', $lock = null, $force = null)
43
	{
44
		$this->indexHandle = fopen("{$this->path}/index.csv", 'r');
45
 
46
		if ($position == 'end') fseek($this->indexHandle, 0, SEEK_END);
47
	}
48
 
49
	protected function makeRequestFromIndex($record)
50
	{
51
		return new Request(array_combine(
52
			[ 'id', 'ip', 'method', 'uri', 'time', 'parent', 'responseStatus' ], $record
53
		));
54
	}
55
}