diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 9f5be9c7b9..7da9fa2e2d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -196,6 +196,7 @@ class FrameworkExtension extends Extension $supported = array( 'sqlite' => 'Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage', 'mysql' => 'Symfony\Component\HttpKernel\Profiler\MysqlProfilerStorage', + 'file' => 'Symfony\Component\HttpKernel\Profiler\FileProfilerStorage', ); list($class, ) = explode(':', $config['dsn']); if (!isset($supported[$class])) { diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php new file mode 100644 index 0000000000..97f6ab5bbc --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -0,0 +1,56 @@ + + */ +class FileProfilerStorage implements ProfilerStorageInterface +{ + protected $folder; + + public function __construct($dsn) + { + if (0 !== strpos($dsn, 'file:')) { + throw new \InvalidArgumentException("FileStorage DSN must start with file:"); + } + $this->folder = substr($dsn, 5); + + if (!is_dir($this->folder)) { + mkdir($this->folder); + } + } + + public function find($ip, $url, $limit) + { + throw new \LogicException("Cannot use find-function with file storage"); + } + + public function purge() + { + $flags = \FilesystemIterator::SKIP_DOTS; + $iterator = new \RecursiveDirectoryIterator($this->folder, $flags); + + foreach ($iterator as $file) + { + die('ON VA SUPPRIMER ' . $file); + } + } + + public function read($token) + { + return unserialize(file_get_contents($this->getFilename($token))); + } + + public function write(Profile $profile) + { + file_put_contents($this->getFilename($profile->getToken()), serialize($profile)); + } + + protected function getFilename($token) + { + return $this->folder . '/' . $token; + } +}