Skip to content

Commit

Permalink
Apply TableRegistry locator setter and getter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Pustułka committed Apr 21, 2017
1 parent 6846686 commit bf52a58
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Datasource/FactoryLocator.php
Expand Up @@ -59,7 +59,7 @@ public static function drop($type)
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])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Network/Session/DatabaseSession.php
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Locator/LocatorAwareTrait.php
Expand Up @@ -67,7 +67,7 @@ public function setTableLocator(LocatorInterface $tableLocator)
public function getTableLocator()
{
if (!$this->_tableLocator) {
$this->_tableLocator = TableRegistry::locator();
$this->_tableLocator = TableRegistry::getTableLocator();
}

return $this->_tableLocator;
Expand Down
14 changes: 7 additions & 7 deletions src/ORM/TableRegistry.php
Expand Up @@ -115,7 +115,7 @@ public static function setTableLocator(LocatorInterface $locator)
*/
public static function config($alias = null, $options = null)
{
return static::locator()->config($alias, $options);
return static::getTableLocator()->config($alias, $options);
}

/**
Expand All @@ -129,7 +129,7 @@ public static function config($alias = null, $options = null)
*/
public static function get($alias, array $options = [])
{
return static::locator()->get($alias, $options);
return static::getTableLocator()->get($alias, $options);
}

/**
Expand All @@ -140,7 +140,7 @@ public static function get($alias, array $options = [])
*/
public static function exists($alias)
{
return static::locator()->exists($alias);
return static::getTableLocator()->exists($alias);
}

/**
Expand All @@ -152,7 +152,7 @@ public static function exists($alias)
*/
public static function set($alias, Table $object)
{
return static::locator()->set($alias, $object);
return static::getTableLocator()->set($alias, $object);
}

/**
Expand All @@ -163,7 +163,7 @@ public static function set($alias, Table $object)
*/
public static function remove($alias)
{
static::locator()->remove($alias);
static::getTableLocator()->remove($alias);
}

/**
Expand All @@ -173,7 +173,7 @@ public static function remove($alias)
*/
public static function clear()
{
static::locator()->clear();
static::getTableLocator()->clear();
}

/**
Expand All @@ -185,6 +185,6 @@ public static function clear()
*/
public static function __callStatic($name, $arguments)
{
return static::locator()->$name(...$arguments);
return static::getTableLocator()->$name(...$arguments);
}
}
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Locator/LocatorAwareTraitTest.php
Expand Up @@ -43,7 +43,7 @@ public function setUp()
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);
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/ORM/TableRegistryTest.php
Expand Up @@ -39,7 +39,7 @@ class TableRegistryTest extends TestCase
public function setUp()
{
parent::setUp();
$this->_originalLocator = TableRegistry::locator();
$this->_originalLocator = TableRegistry::getTableLocator();
}

/**
Expand All @@ -50,7 +50,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
TableRegistry::locator($this->_originalLocator);
TableRegistry::setTableLocator($this->_originalLocator);
}

/**
Expand All @@ -61,7 +61,7 @@ public function tearDown()
protected function _setMockLocator()
{
$locator = $this->getMockBuilder('Cake\ORM\Locator\LocatorInterface')->getMock();
TableRegistry::locator($locator);
TableRegistry::setTableLocator($locator);

return $locator;
}
Expand All @@ -73,11 +73,11 @@ protected function _setMockLocator()
*/
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());
}

/**
Expand All @@ -87,7 +87,7 @@ public function testLocator()
*/
public function testLocatorDefault()
{
$locator = TableRegistry::locator();
$locator = TableRegistry::getTableLocator();
$this->assertInstanceOf('Cake\ORM\Locator\TableLocator', $locator);
}

Expand Down

0 comments on commit bf52a58

Please sign in to comment.