Browse Source

Move Datasource\LocatorInterface to Datasource\Loctor\LocatorInterface

ADmad 5 years ago
parent
commit
4473926a01

+ 5 - 4
src/Datasource/FactoryLocator.php

@@ -16,6 +16,7 @@ declare(strict_types=1);
  */
 namespace Cake\Datasource;
 
+use Cake\Datasource\Locator\LocatorInterface;
 use Cake\ORM\Locator\TableLocator;
 use InvalidArgumentException;
 
@@ -27,7 +28,7 @@ class FactoryLocator
     /**
      * A list of model factory functions.
      *
-     * @var (callable|\Cake\Datasource\LocatorInterface)[]
+     * @var (callable|\Cake\Datasource\Locator\LocatorInterface)[]
      */
     protected static $_modelFactories = [];
 
@@ -35,14 +36,14 @@ class FactoryLocator
      * Register a callable to generate repositories of a given type.
      *
      * @param string $type The name of the repository type the factory function is for.
-     * @param callable|\Cake\Datasource\LocatorInterface $factory The factory function used to create instances.
+     * @param callable|\Cake\Datasource\Locator\LocatorInterface $factory The factory function used to create instances.
      * @return void
      */
     public static function add(string $type, $factory): void
     {
         if (!$factory instanceof LocatorInterface && !is_callable($factory)) {
             throw new InvalidArgumentException(sprintf(
-                '`$factory` must be an instance of Cake\Datasource\LocatorInterface or a callable.'
+                '`$factory` must be an instance of Cake\Datasource\Locator\LocatorInterface or a callable.'
                 . ' Got type `%s` instead.',
                 getTypeName($factory)
             ));
@@ -67,7 +68,7 @@ class FactoryLocator
      *
      * @param string $type The repository type to get the factory for.
      * @throws \InvalidArgumentException If the specified repository type has no factory.
-     * @return callable|\Cake\Datasource\LocatorInterface The factory for the repository type.
+     * @return callable|\Cake\Datasource\Locator\LocatorInterface The factory for the repository type.
      */
     public static function get(string $type)
     {

+ 3 - 1
src/Datasource/LocatorInterface.php

@@ -14,7 +14,9 @@ declare(strict_types=1);
  * @since         4.1.0
  * @license       https://opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Datasource;
+namespace Cake\Datasource\Locator;
+
+use Cake\Datasource\RepositoryInterface;
 
 /**
  * Registries for repository objects should implement this interface.

+ 4 - 3
src/Datasource/ModelAwareTrait.php

@@ -17,6 +17,7 @@ declare(strict_types=1);
 namespace Cake\Datasource;
 
 use Cake\Datasource\Exception\MissingModelException;
+use Cake\Datasource\Locator\LocatorInterface;
 use InvalidArgumentException;
 use UnexpectedValueException;
 
@@ -47,7 +48,7 @@ trait ModelAwareTrait
     /**
      * A list of overridden model factory functions.
      *
-     * @var (callable|\Cake\Datasource\LocatorInterface)[]
+     * @var (callable|\Cake\Datasource\Locator\LocatorInterface)[]
      */
     protected $_modelFactories = [];
 
@@ -134,14 +135,14 @@ trait ModelAwareTrait
      * Override a existing callable to generate repositories of a given type.
      *
      * @param string $type The name of the repository type the factory function is for.
-     * @param callable|\Cake\Datasource\LocatorInterface $factory The factory function used to create instances.
+     * @param callable|\Cake\Datasource\Locator\LocatorInterface $factory The factory function used to create instances.
      * @return void
      */
     public function modelFactory(string $type, $factory): void
     {
         if (!$factory instanceof LocatorInterface && !is_callable($factory)) {
             throw new InvalidArgumentException(sprintf(
-                '`$factory` must be an instance of Cake\Datasource\LocatorInterface or a callable.'
+                '`$factory` must be an instance of Cake\Datasource\Locator\LocatorInterface or a callable.'
                 . ' Got type `%s` instead.',
                 getTypeName($factory)
             ));

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

@@ -22,7 +22,7 @@ use Cake\ORM\Table;
 /**
  * Registries for Table objects should implement this interface.
  */
-interface LocatorInterface extends \Cake\Datasource\LocatorInterface
+interface LocatorInterface extends \Cake\Datasource\Locator\LocatorInterface
 {
     /**
      * Get a table instance from the registry.

+ 2 - 2
tests/TestCase/Datasource/FactoryLocatorTest.php

@@ -16,7 +16,7 @@ declare(strict_types=1);
 namespace Cake\Test\TestCase\Datasource;
 
 use Cake\Datasource\FactoryLocator;
-use Cake\Datasource\LocatorInterface;
+use Cake\Datasource\Locator\LocatorInterface;
 use Cake\TestSuite\TestCase;
 use InvalidArgumentException;
 
@@ -72,7 +72,7 @@ class FactoryLocatorTest extends TestCase
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionMessage(
-            '`$factory` must be an instance of Cake\Datasource\LocatorInterface or a callable.'
+            '`$factory` must be an instance of Cake\Datasource\Locator\LocatorInterface or a callable.'
             . ' Got type `string` instead.'
         );
 

+ 2 - 2
tests/TestCase/Datasource/ModelAwareTraitTest.php

@@ -16,7 +16,7 @@ declare(strict_types=1);
 namespace Cake\Test\TestCase\Datasource;
 
 use Cake\Datasource\FactoryLocator;
-use Cake\Datasource\LocatorInterface;
+use Cake\Datasource\Locator\LocatorInterface;
 use Cake\Datasource\RepositoryInterface;
 use Cake\TestSuite\TestCase;
 use InvalidArgumentException;
@@ -147,7 +147,7 @@ class ModelAwareTraitTest extends TestCase
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionMessage(
-            '`$factory` must be an instance of Cake\Datasource\LocatorInterface or a callable.'
+            '`$factory` must be an instance of Cake\Datasource\Locator\LocatorInterface or a callable.'
             . ' Got type `string` instead.'
         );