Removing E_STRICT errors from ClassRegistry

This commit is contained in:
José Lorenzo Rodríguez 2010-11-08 22:35:55 -04:30
parent 09011d1010
commit 62017b2e38

View file

@ -64,7 +64,7 @@ class ClassRegistry {
public static function &getInstance() { public static function &getInstance() {
static $instance = array(); static $instance = array();
if (!$instance) { if (!$instance) {
$instance[0] =& new ClassRegistry(); $instance[0] = new ClassRegistry();
} }
return $instance[0]; return $instance[0];
} }
@ -94,7 +94,7 @@ class ClassRegistry {
* @return object instance of ClassName * @return object instance of ClassName
*/ */
public static function &init($class, $type = null) { public static function &init($class, $type = null) {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
$id = $false = false; $id = $false = false;
$true = true; $true = true;
@ -129,13 +129,13 @@ class ClassRegistry {
} }
$alias = $settings['alias']; $alias = $settings['alias'];
if ($model =& $_this->__duplicate($alias, $class)) { if ($model = $_this->__duplicate($alias, $class)) {
$_this->map($alias, $class); $_this->map($alias, $class);
return $model; return $model;
} }
if (class_exists($class) || App::import($type, $pluginPath . $class)) { if (class_exists($class) || App::import($type, $pluginPath . $class)) {
${$class} =& new $class($settings); ${$class} = new $class($settings);
} elseif ($type === 'Model') { } elseif ($type === 'Model') {
if ($plugin && class_exists($plugin . 'AppModel')) { if ($plugin && class_exists($plugin . 'AppModel')) {
$appModel = $plugin . 'AppModel'; $appModel = $plugin . 'AppModel';
@ -143,7 +143,7 @@ class ClassRegistry {
$appModel = 'AppModel'; $appModel = 'AppModel';
} }
$settings['name'] = $class; $settings['name'] = $class;
${$class} =& new $appModel($settings); ${$class} = new $appModel($settings);
} }
if (!isset(${$class})) { if (!isset(${$class})) {
@ -176,10 +176,10 @@ class ClassRegistry {
* @return boolean True if the object was written, false if $key already exists * @return boolean True if the object was written, false if $key already exists
*/ */
public static function addObject($key, &$object) { public static function addObject($key, &$object) {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
$key = Inflector::underscore($key); $key = Inflector::underscore($key);
if (!isset($_this->__objects[$key])) { if (!isset($_this->__objects[$key])) {
$_this->__objects[$key] =& $object; $_this->__objects[$key] = $object;
return true; return true;
} }
return false; return false;
@ -192,7 +192,7 @@ class ClassRegistry {
* @return void * @return void
*/ */
public static function removeObject($key) { public static function removeObject($key) {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
$key = Inflector::underscore($key); $key = Inflector::underscore($key);
if (isset($_this->__objects[$key])) { if (isset($_this->__objects[$key])) {
unset($_this->__objects[$key]); unset($_this->__objects[$key]);
@ -206,7 +206,7 @@ class ClassRegistry {
* @return boolean true if key exists in registry, false otherwise * @return boolean true if key exists in registry, false otherwise
*/ */
public static function isKeySet($key) { public static function isKeySet($key) {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
$key = Inflector::underscore($key); $key = Inflector::underscore($key);
if (isset($_this->__objects[$key])) { if (isset($_this->__objects[$key])) {
return true; return true;
@ -222,7 +222,7 @@ class ClassRegistry {
* @return array Set of keys stored in registry * @return array Set of keys stored in registry
*/ */
public static function keys() { public static function keys() {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
return array_keys($_this->__objects); return array_keys($_this->__objects);
} }
@ -233,15 +233,15 @@ class ClassRegistry {
* @return mixed Object stored in registry or boolean false if the object does not exist. * @return mixed Object stored in registry or boolean false if the object does not exist.
*/ */
public static function &getObject($key) { public static function &getObject($key) {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
$key = Inflector::underscore($key); $key = Inflector::underscore($key);
$return = false; $return = false;
if (isset($_this->__objects[$key])) { if (isset($_this->__objects[$key])) {
$return =& $_this->__objects[$key]; $return = $_this->__objects[$key];
} else { } else {
$key = $_this->__getMap($key); $key = $_this->__getMap($key);
if (isset($_this->__objects[$key])) { if (isset($_this->__objects[$key])) {
$return =& $_this->__objects[$key]; $return = $_this->__objects[$key];
} }
} }
return $return; return $return;
@ -257,7 +257,7 @@ class ClassRegistry {
* the previously-set value of $param, or null if not set. * the previously-set value of $param, or null if not set.
*/ */
public static function config($type, $param = array()) { public static function config($type, $param = array()) {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
if (empty($param) && is_array($type)) { if (empty($param) && is_array($type)) {
$param = $type; $param = $type;
@ -280,9 +280,9 @@ class ClassRegistry {
private function &__duplicate($alias, $class) { private function &__duplicate($alias, $class) {
$duplicate = false; $duplicate = false;
if ($this->isKeySet($alias)) { if ($this->isKeySet($alias)) {
$model =& $this->getObject($alias); $model = $this->getObject($alias);
if (is_object($model) && (is_a($model, $class) || $model->alias === $class)) { if (is_object($model) && (is_a($model, $class) || $model->alias === $class)) {
$duplicate =& $model; $duplicate = $model;
} }
unset($model); unset($model);
} }
@ -296,7 +296,7 @@ class ClassRegistry {
* @param string $name Key that is being mapped * @param string $name Key that is being mapped
*/ */
public static function map($key, $name) { public static function map($key, $name) {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
$key = Inflector::underscore($key); $key = Inflector::underscore($key);
$name = Inflector::underscore($name); $name = Inflector::underscore($name);
if (!isset($_this->__map[$key])) { if (!isset($_this->__map[$key])) {
@ -310,7 +310,7 @@ class ClassRegistry {
* @return array Keys of registry's map * @return array Keys of registry's map
*/ */
public static function mapKeys() { public static function mapKeys() {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
return array_keys($_this->__map); return array_keys($_this->__map);
} }
@ -332,7 +332,7 @@ class ClassRegistry {
* @return void * @return void
*/ */
public static function flush() { public static function flush() {
$_this =& ClassRegistry::getInstance(); $_this = ClassRegistry::getInstance();
$_this->__objects = array(); $_this->__objects = array();
$_this->__map = array(); $_this->__map = array();
} }