Skip to content

Commit

Permalink
Use LocatorAwareTrait in DatabaseSession.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpustulka committed Sep 21, 2017
1 parent 3e74680 commit a078e01
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Network/Session/DatabaseSession.php
Expand Up @@ -18,14 +18,15 @@
namespace Cake\Network\Session;

use Cake\ORM\Entity;
use Cake\ORM\Locator\TableLocator;
use Cake\ORM\Locator\LocatorAwareTrait;
use SessionHandlerInterface;

/**
* DatabaseSession provides methods to be used with Session.
*/
class DatabaseSession implements SessionHandlerInterface
{
use LocatorAwareTrait;

/**
* Reference to the table handling the session data
Expand All @@ -50,7 +51,10 @@ class DatabaseSession implements SessionHandlerInterface
*/
public function __construct(array $config = [])
{
$tableLocator = isset($config['tableLocator']) ? $config['tableLocator'] : TableLocator::getInstance();
if (isset($config['tableLocator'])) {
$this->setTableLocator($config['tableLocator']);
}
$tableLocator = $this->getTableLocator();

if (empty($config['model'])) {
$config = $tableLocator->exists('Sessions') ? [] : ['table' => 'sessions'];
Expand Down

0 comments on commit a078e01

Please sign in to comment.