Browse Source

Use LocatorAwareTrait in DatabaseSession.

Robert Pustułka 8 years ago
parent
commit
a078e01490
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/Network/Session/DatabaseSession.php

+ 6 - 2
src/Network/Session/DatabaseSession.php

@@ -18,7 +18,7 @@
 namespace Cake\Network\Session;
 
 use Cake\ORM\Entity;
-use Cake\ORM\Locator\TableLocator;
+use Cake\ORM\Locator\LocatorAwareTrait;
 use SessionHandlerInterface;
 
 /**
@@ -26,6 +26,7 @@ use SessionHandlerInterface;
  */
 class DatabaseSession implements SessionHandlerInterface
 {
+    use LocatorAwareTrait;
 
     /**
      * Reference to the table handling the session data
@@ -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'];