[ Index ] |
|
Code source de CakePHP 1.1.13.4450 |
1 <?php 2 /* SVN FILE: $Id: class_registry.php 4450 2007-02-05 05:18:05Z phpnut $ */ 3 /** 4 * Class collections. 5 * 6 * A repository for class objects, each registered with a key. 7 * 8 * PHP versions 4 and 5 9 * 10 * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> 11 * Copyright 2005-2007, Cake Software Foundation, Inc. 12 * 1785 E. Sahara Avenue, Suite 490-204 13 * Las Vegas, Nevada 89104 14 * 15 * Licensed under The MIT License 16 * Redistributions of files must retain the above copyright notice. 17 * 18 * @filesource 19 * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. 20 * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project 21 * @package cake 22 * @subpackage cake.cake.libs 23 * @since CakePHP(tm) v 0.9.2 24 * @version $Revision: 4450 $ 25 * @modifiedby $LastChangedBy: phpnut $ 26 * @lastmodified $Date: 2007-02-04 23:18:05 -0600 (Sun, 04 Feb 2007) $ 27 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 28 */ 29 /** 30 * Class Collections. 31 * 32 * A repository for class objects, each registered with a key. 33 * If you try to add an object with the same key twice, nothing will come of it. 34 * If you need a second instance of an object, give it another key. 35 * 36 * @package cake 37 * @subpackage cake.cake.libs 38 */ 39 class ClassRegistry{ 40 /** 41 * Names of classes with their objects. 42 * 43 * @var array 44 * @access private 45 */ 46 var $_objects = array(); 47 /** 48 * Return a singleton instance of the ClassRegistry. 49 * 50 * @return ClassRegistry instance 51 */ 52 function &getInstance() { 53 static $instance = array(); 54 if (!$instance) { 55 $instance[0] = &new ClassRegistry; 56 } 57 return $instance[0]; 58 } 59 /** 60 * Add $object to the registry, associating it with the name $key. 61 * 62 * @param string $key 63 * @param mixed $object 64 */ 65 function addObject($key, &$object) { 66 $_this =& ClassRegistry::getInstance(); 67 $key = strtolower($key); 68 if (array_key_exists($key, $_this->_objects) === false) { 69 $_this->_objects[$key] = &$object; 70 } 71 } 72 /** 73 * Remove object which corresponds to given key. 74 * 75 * @param string $key 76 * @return void 77 */ 78 function removeObject($key) { 79 $_this =& ClassRegistry::getInstance(); 80 $key = strtolower($key); 81 if (array_key_exists($key, $_this->_objects) === true) { 82 unset($_this->_objects[$key]); 83 } 84 } 85 /** 86 * Returns true if given key is present in the ClassRegistry. 87 * 88 * @param string $key Key to look for 89 * @return boolean Success 90 */ 91 function isKeySet($key) { 92 $_this =& ClassRegistry::getInstance(); 93 $key = strtolower($key); 94 return array_key_exists($key, $_this->_objects); 95 } 96 /** 97 * Return object which corresponds to given key. 98 * 99 * @param string $key 100 * @return mixed 101 */ 102 function &getObject($key) { 103 $_this =& ClassRegistry::getInstance(); 104 $key = strtolower($key); 105 return $_this->_objects[$key]; 106 } 107 } 108 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 19:27:47 2007 | par Balluche grâce à PHPXref 0.7 |