Skip to content

Commit

Permalink
Refactored Registry to Locator.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpustulka committed Apr 9, 2015
1 parent 5197cd5 commit d65fc3f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Expand Up @@ -14,14 +14,14 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

namespace Cake\ORM\Registry;
namespace Cake\ORM\Locator;

use Cake\ORM\Table;

/**
* Registries for Table objects should implement this interface.
*/
interface RegistryInterface
interface LocatorInterface
{

/**
Expand Down
Expand Up @@ -14,19 +14,19 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

namespace Cake\ORM\Registry;
namespace Cake\ORM\Locator;

use Cake\Core\App;
use Cake\Datasource\ConnectionManager;
use Cake\ORM\Registry\RegistryInterface;
use Cake\ORM\Locator\LocatorInterface;
use Cake\ORM\Table;
use Cake\Utility\Inflector;
use RuntimeException;

/**
* Provides a default registry/factory for Table objects.
*/
class DefaultRegistry implements RegistryInterface
class TableLocator implements LocatorInterface
{

/**
Expand Down
18 changes: 9 additions & 9 deletions src/ORM/TableRegistry.php
Expand Up @@ -16,7 +16,7 @@

namespace Cake\ORM;

use Cake\ORM\Registry\RegistryInterface;
use Cake\ORM\Locator\LocatorInterface;

/**
* Provides a registry/factory for Table objects.
Expand Down Expand Up @@ -56,31 +56,31 @@ class TableRegistry
/**
* Singleton for static calls.
*
* @var \Cake\ORM\Registry\RegistryInterface
* @var \Cake\ORM\Locator\LocatorInterface
*/
protected static $_instance;

/**
* Default RegistryInterface implementation class.
* Default LocatorInterface implementation class.
*
* @var string
*/
protected static $_defaultRegistryClass = 'Cake\ORM\Registry\DefaultRegistry';
protected static $_defaultLocatorClass = 'Cake\ORM\Locator\TableLocator';

/**
* Sets and returns singleton instance of Registry.
* Sets and returns singleton instance of a LocatorInterface.
*
* @param \Cake\ORM\Registry\RegistryInterface $instance Instance of registry to set.
* @return \Cake\ORM\Registry\RegistryInterface
* @param \Cake\ORM\Locator\LocatorInterface $instance Instance of registry to set.
* @return \Cake\ORM\Locator\LocatorInterface
*/
public static function instance(RegistryInterface $instance = null)
public static function instance(LocatorInterface $instance = null)
{
if ($instance) {
static::$_instance = $instance;
}

if (!static::$_instance) {
static::$_instance = new static::$_defaultRegistryClass;
static::$_instance = new static::$_defaultLocatorClass;
}

return static::$_instance;
Expand Down

0 comments on commit d65fc3f

Please sign in to comment.