Skip to content
Permalink
Browse files

Moving ObjectRegistry to the Core namespace as it is a very central c…

…oncept
  • Loading branch information...
lorenzo committed Aug 26, 2014
1 parent 9d3c954 commit 88577a64750be24077aa2666ca2624e1fb010300
@@ -16,7 +16,7 @@
use Cake\Core\App;
use Cake\Error;
use Cake\Utility\ObjectRegistry;
use Cake\Core\ObjectRegistry;
/**
* An object registry for cache engines.
@@ -28,7 +28,7 @@ class CacheRegistry extends ObjectRegistry {
/**
* Resolve a cache engine classname.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class Partial classname to resolve.
* @return string|false Either the correct classname or false.
@@ -43,7 +43,7 @@ protected function _resolveClassName($class) {
/**
* Throws an exception when a cache engine is missing.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the cache is missing in.
@@ -57,7 +57,7 @@ protected function _throwMissingClassError($class, $plugin) {
/**
* Create the cache engine instance.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string|CacheEngine $class The classname or object to make.
* @param string $alias The alias of the object.
@@ -15,7 +15,7 @@
namespace Cake\Console;
use Cake\Core\App;
use Cake\Utility\ObjectRegistry;
use Cake\Core\ObjectRegistry;
/**
* Registry for Tasks. Provides features
@@ -42,7 +42,7 @@ public function __construct(Shell $Shell) {
/**
* Resolve a task classname.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class Partial classname to resolve.
* @return string|false Either the correct classname or false.
@@ -54,7 +54,7 @@ protected function _resolveClassName($class) {
/**
* Throws an exception when a task is missing.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the task is missing in.
@@ -71,7 +71,7 @@ protected function _throwMissingClassError($class, $plugin) {
/**
* Create the task instance.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class The classname to create.
* @param string $alias The alias of the task.
@@ -16,7 +16,7 @@
use Cake\Core\App;
use Cake\Event\EventManagerTrait;
use Cake\Utility\ObjectRegistry;
use Cake\Core\ObjectRegistry;
/**
* ComponentRegistry is a registry for loaded components
@@ -58,7 +58,7 @@ public function getController() {
/**
* Resolve a component classname.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class Partial classname to resolve.
* @return string|false Either the correct classname or false.
@@ -70,7 +70,7 @@ protected function _resolveClassName($class) {
/**
* Throws an exception when a component is missing.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the component is missing in.
@@ -87,7 +87,7 @@ protected function _throwMissingClassError($class, $plugin) {
/**
* Create the component instance.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
* Enabled components will be registered with the event manager.
*
* @param string $class The classname to create.
@@ -0,0 +1,160 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Utility;
use Cake\Core\App;
use Cake\Core\Plugin;
use Cake\Utility\Inflector;
/**
* Provides methods that allow other classes access to conventions based inflections.
*/
trait ConventionsTrait {
/**
* Creates the proper controller plural name for the specified controller class name
*
* @param string $name Controller class name
* @return string Controller plural name
*/
protected function _controllerName($name) {
return Inflector::pluralize(Inflector::camelize($name));
}
/**
* Creates a fixture name
*
* @param string $name Model class name
* @return string Singular model key
*/
protected function _fixtureName($name) {
return Inflector::underscore(Inflector::singularize($name));
}
/**
* Creates the proper model camelized name (plural) for the specified name
*
* @param string $name Name
* @return string Camelized and plural model name
*/
protected function _modelName($name) {
return Inflector::pluralize(Inflector::camelize($name));
}
/**
* Creates the proper entity name (singular) for the specified name
*
* @param string $name Name
* @return string Camelized and plural model name
*/
protected function _entityName($name) {
return Inflector::singularize(Inflector::camelize($name));
}
/**
* Creates the proper underscored model key for associations
*
* @param string $name Model class name
* @return string Singular model key
*/
protected function _modelKey($name) {
return Inflector::underscore(Inflector::singularize($name)) . '_id';
}
/**
* Creates the proper model name from a foreign key
*
* @param string $key Foreign key
* @return string Model name
*/
protected function _modelNameFromKey($key) {
$key = str_replace('_id', '', $key);
return $this->_modelName($key);
}
/**
* Creates the singular name for use in views.
*
* @param string $name Name to use
* @return string Variable name
*/
protected function _singularName($name) {
return Inflector::variable(Inflector::singularize($name));
}
/**
* Creates the plural name for views
*
* @param string $name Name to use
* @return string Plural name for views
*/
protected function _pluralName($name) {
return Inflector::variable(Inflector::pluralize($name));
}
/**
* Creates the singular human name used in views
*
* @param string $name Controller name
* @return string Singular human name
*/
protected function _singularHumanName($name) {
return Inflector::humanize(Inflector::underscore(Inflector::singularize($name)));
}
/**
* Creates a camelized version of $name
*
* @param string $name name
* @return string Camelized name
*/
protected function _camelize($name) {
return Inflector::camelize($name);
}
/**
* Creates the plural human name used in views
*
* @param string $name Controller name
* @return string Plural human name
*/
protected function _pluralHumanName($name) {
return Inflector::humanize(Inflector::underscore($name));
}
/**
* Find the correct path for a plugin. Scans $pluginPaths for the plugin you want.
*
* @param string $pluginName Name of the plugin you want ie. DebugKit
* @return string path path to the correct plugin.
*/
protected function _pluginPath($pluginName) {
if (Plugin::loaded($pluginName)) {
return Plugin::path($pluginName);
}
return current(App::path('Plugin')) . $pluginName . DS;
}
/**
* Return plugin's namespace
*
* @param string $pluginName Plugin name
* @return string Plugin's namespace
*/
protected function _pluginNamespace($pluginName) {
return str_replace('/', '\\', $pluginName);
}
}
@@ -12,7 +12,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Utility;
namespace Cake\Core;
/**
* Acts as a registry/factory for objects.
@@ -16,7 +16,7 @@
use Cake\Core\App;
use Cake\Datasource\Error\MissingDatasourceException;
use Cake\Utility\ObjectRegistry;
use Cake\Core\ObjectRegistry;
/**
* A registry object for connection instances.
@@ -28,7 +28,7 @@ class ConnectionRegistry extends ObjectRegistry {
/**
* Resolve a driver classname.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class Partial classname to resolve.
* @return string|false Either the correct classname or false.
@@ -43,7 +43,7 @@ protected function _resolveClassName($class) {
/**
* Throws an exception when a driver is missing
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the driver is missing in.
@@ -60,7 +60,7 @@ protected function _throwMissingClassError($class, $plugin) {
/**
* Create the connection object with the correct settings.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string|object $class The classname or object to make.
* @param string $alias The alias of the object.
@@ -17,7 +17,7 @@
use Cake\Core\App;
use Cake\Error;
use Cake\Log\LogInterface;
use Cake\Utility\ObjectRegistry;
use Cake\Core\ObjectRegistry;
/**
* Registry of loaded log engines
@@ -27,7 +27,7 @@ class LogEngineRegistry extends ObjectRegistry {
/**
* Resolve a logger classname.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class Partial classname to resolve.
* @return string|false Either the correct classname or false.
@@ -43,7 +43,7 @@ protected function _resolveClassName($class) {
/**
* Throws an exception when a logger is missing.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the logger is missing in.
@@ -57,7 +57,7 @@ protected function _throwMissingClassError($class, $plugin) {
/**
* Create the logger instance.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string|LogInterface $class The classname or object to make.
* @param string $alias The alias of the object.
@@ -19,7 +19,7 @@
use Cake\Event\EventManagerTrait;
use Cake\ORM\Behavior;
use Cake\ORM\Table;
use Cake\Utility\ObjectRegistry;
use Cake\Core\ObjectRegistry;
/**
* BehaviorRegistry is used as a registry for loaded behaviors and handles loading
@@ -65,7 +65,7 @@ public function __construct(Table $table) {
/**
* Resolve a behavior classname.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class Partial classname to resolve.
* @return string|false Either the correct classname or false.
@@ -77,7 +77,7 @@ protected function _resolveClassName($class) {
/**
* Throws an exception when a behavior is missing.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the behavior is missing in.
@@ -94,7 +94,7 @@ protected function _throwMissingClassError($class, $plugin) {
/**
* Create the behavior instance.
*
* Part of the template method for Cake\Utility\ObjectRegistry::load()
* Part of the template method for Cake\Core\ObjectRegistry::load()
* Enabled behaviors will be registered with the event manager.
*
* @param string $class The classname that is missing.
Oops, something went wrong.

0 comments on commit 88577a6

Please sign in to comment.
You can’t perform that action at this time.