[DoctrineBridge] Refactor session storage to handler.
This commit is contained in:
parent
a1c678ecd7
commit
a6a9280a3b
@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\HttpFoundation;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\AbstractSessionStorage;
|
||||
use Doctrine\DBAL\Driver\Connection;
|
||||
|
||||
/**
|
||||
@ -12,7 +20,7 @@ use Doctrine\DBAL\Driver\Connection;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class DbalSessionStorage extends AbstractSessionStorage implements \SessionHandlerInterface
|
||||
class DbalSessionHandler implements \SessionHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
@ -25,26 +33,19 @@ class DbalSessionStorage extends AbstractSessionStorage implements \SessionHandl
|
||||
private $tableName;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Connection $con An instance of Connection.
|
||||
* @param string $tableName Table name.
|
||||
* @param array $options Session configuration options
|
||||
*/
|
||||
public function __construct(Connection $con, $tableName = 'sessions', array $options = array())
|
||||
public function __construct(Connection $con, $tableName = 'sessions')
|
||||
{
|
||||
$this->con = $con;
|
||||
$this->tableName = $tableName;
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a session.
|
||||
*
|
||||
* @param string $path (ignored)
|
||||
* @param string $name (ignored)
|
||||
*
|
||||
* @return Boolean true, if the session was opened, otherwise an exception is thrown
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function open($path = null, $name = null)
|
||||
{
|
||||
@ -52,9 +53,7 @@ class DbalSessionStorage extends AbstractSessionStorage implements \SessionHandl
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a session.
|
||||
*
|
||||
* @return Boolean true, if the session was closed, otherwise false
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
@ -63,13 +62,7 @@ class DbalSessionStorage extends AbstractSessionStorage implements \SessionHandl
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a session.
|
||||
*
|
||||
* @param string $id A session ID
|
||||
*
|
||||
* @return Boolean true, if the session was destroyed, otherwise an exception is thrown
|
||||
*
|
||||
* @throws \RuntimeException If the session cannot be destroyed
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
@ -85,13 +78,7 @@ class DbalSessionStorage extends AbstractSessionStorage implements \SessionHandl
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up old sessions.
|
||||
*
|
||||
* @param int $lifetime The lifetime of a session
|
||||
*
|
||||
* @return Boolean true, if old sessions have been cleaned, otherwise an exception is thrown
|
||||
*
|
||||
* @throws \RuntimeException If any old sessions cannot be cleaned
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function gc($lifetime)
|
||||
{
|
||||
@ -107,13 +94,7 @@ class DbalSessionStorage extends AbstractSessionStorage implements \SessionHandl
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a session.
|
||||
*
|
||||
* @param string $id A session ID
|
||||
*
|
||||
* @return string The session data if the session was read or created, otherwise an exception is thrown
|
||||
*
|
||||
* @throws \RuntimeException If the session cannot be read
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
@ -136,14 +117,7 @@ class DbalSessionStorage extends AbstractSessionStorage implements \SessionHandl
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes session data.
|
||||
*
|
||||
* @param string $id A session ID
|
||||
* @param string $data A serialized chunk of session data
|
||||
*
|
||||
* @return Boolean true, if the session was written, otherwise an exception is thrown
|
||||
*
|
||||
* @throws \RuntimeException If the session data cannot be written
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($id, $data)
|
||||
{
|
@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\HttpFoundation;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@ -9,7 +18,7 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
final class DbalSessionStorageSchema extends Schema
|
||||
final class DbalSessionHandlerSchema extends Schema
|
||||
{
|
||||
private $tableName;
|
||||
|
Reference in New Issue
Block a user