continued ioc refactoring.

This commit is contained in:
Taylor Otwell
2011-08-26 21:42:04 -05:00
parent fb3a0df0dd
commit 1e49001dfc
44 changed files with 1388 additions and 1046 deletions

View File

@@ -9,15 +9,24 @@ class File extends Driver implements Sweeper {
*/
private $file;
/**
* The path to which the session files should be written.
*
* @var string
*/
private $path;
/**
* Create a new File session driver instance.
*
* @param Laravel\File $file
* @param string $path
* @return void
*/
public function __construct(\Laravel\File $file)
public function __construct(\Laravel\File $file, $path)
{
$this->file = $file;
$this->path = $path;
}
/**
@@ -31,7 +40,7 @@ class File extends Driver implements Sweeper {
*/
protected function load($id)
{
if ($this->file->exists($path = SESSION_PATH.$id)) return unserialize($this->file->get($path));
if ($this->file->exists($path = $this->path.$id)) return unserialize($this->file->get($path));
}
/**
@@ -41,7 +50,7 @@ class File extends Driver implements Sweeper {
*/
protected function save()
{
$this->file->put(SESSION_PATH.$this->session['id'], serialize($this->session), LOCK_EX);
$this->file->put($this->path.$this->session['id'], serialize($this->session), LOCK_EX);
}
/**
@@ -51,7 +60,7 @@ class File extends Driver implements Sweeper {
*/
protected function delete()
{
$this->file->delete(SESSION_PATH.$this->session['id']);
$this->file->delete($this->path.$this->session['id']);
}
/**
@@ -62,7 +71,7 @@ class File extends Driver implements Sweeper {
*/
public function sweep($expiration)
{
foreach (glob(SESSION_PATH.'*') as $file)
foreach (glob($this->path.'*') as $file)
{
if ($this->file->type($file) == 'file' and $this->file->modified($file) < $expiration) $this->file->delete($file);
}