Browse Source

Rename locator() to tableLocator().

Robert 11 years ago
parent
commit
1b983826a0

+ 1 - 1
src/Controller/Controller.php

@@ -272,7 +272,7 @@ class Controller implements EventListenerInterface
             $this->eventManager($eventManager);
         }
 
-        $this->modelFactory('Table', [$this->locator(), 'get']);
+        $this->modelFactory('Table', [$this->tableLocator(), 'get']);
         $modelClass = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
         $this->_setModelClass($modelClass);
 

+ 3 - 3
src/ORM/Association.php

@@ -200,7 +200,7 @@ abstract class Association
             'finder',
             'foreignKey',
             'joinType',
-            'locator',
+            'tableLocator',
             'propertyName',
             'sourceTable',
             'targetTable'
@@ -295,10 +295,10 @@ abstract class Association
         }
 
         $config = [];
-        if (!$this->locator()->exists($registryAlias)) {
+        if (!$this->tableLocator()->exists($registryAlias)) {
             $config = ['className' => $this->_className];
         }
-        $this->_targetTable = $this->locator()->get($registryAlias, $config);
+        $this->_targetTable = $this->tableLocator()->get($registryAlias, $config);
 
         return $this->_targetTable;
     }

+ 3 - 3
src/ORM/Association/BelongsToMany.php

@@ -176,15 +176,15 @@ class BelongsToMany extends Association
                 $tableAlias = Inflector::camelize($tableName);
 
                 $config = [];
-                if (!$this->locator()->exists($tableAlias)) {
+                if (!$this->tableLocator()->exists($tableAlias)) {
                     $config = ['table' => $tableName];
                 }
-                $table = $this->locator()->get($tableAlias, $config);
+                $table = $this->tableLocator()->get($tableAlias, $config);
             }
         }
 
         if (is_string($table)) {
-            $table = $this->locator()->get($table);
+            $table = $this->tableLocator()->get($table);
         }
         $junctionAlias = $table->alias();
 

+ 7 - 7
src/ORM/Behavior/TranslateBehavior.php

@@ -81,7 +81,7 @@ class TranslateBehavior extends Behavior
         'allowEmptyTranslations' => true,
         'onlyTranslated' => false,
         'strategy' => 'subquery',
-        'locator' => null
+        'tableLocator' => null
     ];
 
     /**
@@ -97,8 +97,8 @@ class TranslateBehavior extends Behavior
             'referenceName' => $this->_referenceName($table)
         ];
 
-        if (isset($config['locator'])) {
-            $this->_locator = $config['locator'];
+        if (isset($config['tableLocator'])) {
+            $this->_tableLocator = $config['tableLocator'];
         }
 
         parent::__construct($table, $config);
@@ -112,7 +112,7 @@ class TranslateBehavior extends Behavior
      */
     public function initialize(array $config)
     {
-        $this->_translationTable = $this->locator()->get($this->_config['translationTable']);
+        $this->_translationTable = $this->tableLocator()->get($this->_config['translationTable']);
 
         $this->setupFieldAssociations(
             $this->_config['fields'],
@@ -145,14 +145,14 @@ class TranslateBehavior extends Behavior
         foreach ($fields as $field) {
             $name = $alias . '_' . $field . '_translation';
 
-            if (!$this->locator()->exists($name)) {
-                $fieldTable = $this->locator()->get($name, [
+            if (!$this->tableLocator()->exists($name)) {
+                $fieldTable = $this->tableLocator()->get($name, [
                     'className' => $table,
                     'alias' => $name,
                     'table' => $this->_translationTable->table()
                 ]);
             } else {
-                $fieldTable = $this->locator()->get($name);
+                $fieldTable = $this->tableLocator()->get($name);
             }
 
             $conditions = [

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

@@ -27,23 +27,23 @@ trait LocatorAwareTrait
      *
      * @var \Cake\ORM\Locator\LocatorInterface
      */
-    protected $_locator;
+    protected $_tableLocator;
 
     /**
      * Sets the table locator.
      * If no parameters are passed, it will return the currently used locator.
      *
-     * @param \Cake\ORM\Locator\LocatorInterface|null $locator LocatorInterface instance.
+     * @param \Cake\ORM\Locator\LocatorInterface|null $tableLocator LocatorInterface instance.
      * @return \Cake\ORM\Locator\LocatorInterface
      */
-    public function locator(LocatorInterface $locator = null)
+    public function tableLocator(LocatorInterface $tableLocator = null)
     {
-        if ($locator !== null) {
-            $this->_locator = $locator;
+        if ($tableLocator !== null) {
+            $this->_tableLocator = $tableLocator;
         }
-        if (!$this->_locator) {
-            $this->_locator = TableRegistry::locator();
+        if (!$this->_tableLocator) {
+            $this->_tableLocator = TableRegistry::locator();
         }
-        return $this->_locator;
+        return $this->_tableLocator;
     }
 }

+ 1 - 1
src/View/Cell.php

@@ -142,7 +142,7 @@ abstract class Cell
         $this->eventManager($eventManager);
         $this->request = $request;
         $this->response = $response;
-        $this->modelFactory('Table', [$this->locator(), 'get']);
+        $this->modelFactory('Table', [$this->tableLocator(), 'get']);
 
         foreach ($this->_validCellOptions as $var) {
             if (isset($cellOptions[$var])) {

+ 2 - 2
tests/TestCase/ORM/AssociationTest.php

@@ -337,13 +337,13 @@ class AssociationTest extends TestCase
         $locator = $this->getMock('Cake\ORM\Locator\LocatorInterface');
         $config = [
             'className' => '\Cake\Test\TestCase\ORM\TestTable',
-            'locator' => $locator
+            'tableLocator' => $locator
         ];
         $assoc = $this->getMock(
             '\Cake\ORM\Association',
             ['type', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'],
             ['Foo', $config]
         );
-        $this->assertEquals($locator, $assoc->locator());
+        $this->assertEquals($locator, $assoc->tableLocator());
     }
 }

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

@@ -37,17 +37,17 @@ class LocatorAwareTraitTest extends TestCase
     }
 
     /**
-     * Tests locator method
+     * Tests tableLocator method
      *
      * @return void
      */
-    public function testLocator()
+    public function testTableLocator()
     {
-        $locator = $this->subject->locator();
-        $this->assertSame(TableRegistry::locator(), $locator);
+        $tableLocator = $this->subject->tableLocator();
+        $this->assertSame(TableRegistry::locator(), $tableLocator);
 
         $newLocator = $this->getMock('Cake\ORM\Locator\LocatorInterface');
-        $subjectLocator = $this->subject->locator($newLocator);
+        $subjectLocator = $this->subject->tableLocator($newLocator);
         $this->assertSame($newLocator, $subjectLocator);
     }
 }