ソースを参照

Apply TableRegistry locator setter and getter.

Robert Pustułka 9 年 前
コミット
bf52a58ea1

+ 1 - 1
src/Datasource/FactoryLocator.php

@@ -59,7 +59,7 @@ class FactoryLocator
     public static function get($type)
     {
         if (!isset(static::$_modelFactories['Table'])) {
-            static::$_modelFactories['Table'] = [TableRegistry::locator(), 'get'];
+            static::$_modelFactories['Table'] = [TableRegistry::getTableLocator(), 'get'];
         }
 
         if (!isset(static::$_modelFactories[$type])) {

+ 1 - 1
src/Network/Session/DatabaseSession.php

@@ -50,7 +50,7 @@ class DatabaseSession implements SessionHandlerInterface
      */
     public function __construct(array $config = [])
     {
-        $tableLocator = isset($config['tableLocator']) ? $config['tableLocator'] : TableRegistry::locator();
+        $tableLocator = isset($config['tableLocator']) ? $config['tableLocator'] : TableRegistry::getTableLocator();
 
         if (empty($config['model'])) {
             $config = $tableLocator->exists('Sessions') ? [] : ['table' => 'sessions'];

+ 1 - 1
src/ORM/Locator/LocatorAwareTrait.php

@@ -67,7 +67,7 @@ trait LocatorAwareTrait
     public function getTableLocator()
     {
         if (!$this->_tableLocator) {
-            $this->_tableLocator = TableRegistry::locator();
+            $this->_tableLocator = TableRegistry::getTableLocator();
         }
 
         return $this->_tableLocator;

+ 7 - 7
src/ORM/TableRegistry.php

@@ -115,7 +115,7 @@ class TableRegistry
      */
     public static function config($alias = null, $options = null)
     {
-        return static::locator()->config($alias, $options);
+        return static::getTableLocator()->config($alias, $options);
     }
 
     /**
@@ -129,7 +129,7 @@ class TableRegistry
      */
     public static function get($alias, array $options = [])
     {
-        return static::locator()->get($alias, $options);
+        return static::getTableLocator()->get($alias, $options);
     }
 
     /**
@@ -140,7 +140,7 @@ class TableRegistry
      */
     public static function exists($alias)
     {
-        return static::locator()->exists($alias);
+        return static::getTableLocator()->exists($alias);
     }
 
     /**
@@ -152,7 +152,7 @@ class TableRegistry
      */
     public static function set($alias, Table $object)
     {
-        return static::locator()->set($alias, $object);
+        return static::getTableLocator()->set($alias, $object);
     }
 
     /**
@@ -163,7 +163,7 @@ class TableRegistry
      */
     public static function remove($alias)
     {
-        static::locator()->remove($alias);
+        static::getTableLocator()->remove($alias);
     }
 
     /**
@@ -173,7 +173,7 @@ class TableRegistry
      */
     public static function clear()
     {
-        static::locator()->clear();
+        static::getTableLocator()->clear();
     }
 
     /**
@@ -185,6 +185,6 @@ class TableRegistry
      */
     public static function __callStatic($name, $arguments)
     {
-        return static::locator()->$name(...$arguments);
+        return static::getTableLocator()->$name(...$arguments);
     }
 }

+ 1 - 1
tests/TestCase/ORM/Locator/LocatorAwareTraitTest.php

@@ -43,7 +43,7 @@ class LocatorAwareTraitTest extends TestCase
     public function testTableLocator()
     {
         $tableLocator = $this->subject->tableLocator();
-        $this->assertSame(TableRegistry::locator(), $tableLocator);
+        $this->assertSame(TableRegistry::getTableLocator(), $tableLocator);
 
         $newLocator = $this->getMockBuilder('Cake\ORM\Locator\LocatorInterface')->getMock();
         $subjectLocator = $this->subject->tableLocator($newLocator);

+ 6 - 6
tests/TestCase/ORM/TableRegistryTest.php

@@ -39,7 +39,7 @@ class TableRegistryTest extends TestCase
     public function setUp()
     {
         parent::setUp();
-        $this->_originalLocator = TableRegistry::locator();
+        $this->_originalLocator = TableRegistry::getTableLocator();
     }
 
     /**
@@ -50,7 +50,7 @@ class TableRegistryTest extends TestCase
     public function tearDown()
     {
         parent::tearDown();
-        TableRegistry::locator($this->_originalLocator);
+        TableRegistry::setTableLocator($this->_originalLocator);
     }
 
     /**
@@ -61,7 +61,7 @@ class TableRegistryTest extends TestCase
     protected function _setMockLocator()
     {
         $locator = $this->getMockBuilder('Cake\ORM\Locator\LocatorInterface')->getMock();
-        TableRegistry::locator($locator);
+        TableRegistry::setTableLocator($locator);
 
         return $locator;
     }
@@ -73,11 +73,11 @@ class TableRegistryTest extends TestCase
      */
     public function testLocator()
     {
-        $this->assertInstanceOf('Cake\ORM\Locator\LocatorInterface', TableRegistry::locator());
+        $this->assertInstanceOf('Cake\ORM\Locator\LocatorInterface', TableRegistry::getTableLocator());
 
         $locator = $this->_setMockLocator();
 
-        $this->assertSame($locator, TableRegistry::locator());
+        $this->assertSame($locator, TableRegistry::getTableLocator());
     }
 
     /**
@@ -87,7 +87,7 @@ class TableRegistryTest extends TestCase
      */
     public function testLocatorDefault()
     {
-        $locator = TableRegistry::locator();
+        $locator = TableRegistry::getTableLocator();
         $this->assertInstanceOf('Cake\ORM\Locator\TableLocator', $locator);
     }