| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/core/src/exception/lmbException.class.php'); 10 11 /** 12 * Registry pattern implementation. 13 * Allows to store any information and get access to it in any point of application 14 * Supports saving and restoring (acts like programming stack) that is usefull for testing 15 * Completely static class 16 * @link http://www.phppatterns.com/docs/design/the_registry 17 * @package toolkit 18 * @version $Id: lmbRegistry.class.php 5945 2007-06-06 08:31:43Z pachanga $ 19 */ 20 class lmbRegistry 21 { 22 protected static $cache = array(array()); 23 24 /** 25 * Adds a value to the registry 26 * @param string key 27 * @param mixed value 28 */ 29 static function set($name, $value) 30 { 31 self :: $cache[$name][0] = $value; 32 } 33 34 /** 35 * Returns value from the registry 36 * @param string key 37 * @return mixed 38 */ 39 static function get($name) 40 { 41 if(isset(self :: $cache[$name][0])) 42 return self :: $cache[$name][0]; 43 } 44 45 /** 46 * Moves all registry entries one level deeper in cache stack 47 * @param string key 48 * @return void 49 */ 50 static function save($name) 51 { 52 if(isset(self :: $cache[$name])) 53 array_unshift(self :: $cache[$name], array()); 54 else 55 throw new lmbException('no such registry entry', array('name' => $name)); 56 } 57 58 /** 59 * Moves all registry entries one level up in cache stack 60 * @param string key 61 * @return void 62 */ 63 static function restore($name) 64 { 65 if(isset(self :: $cache[$name])) 66 array_shift(self :: $cache[$name]); 67 else 68 throw new lmbException('no such registry entry', array('name' => $name)); 69 } 70 } 71 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Dec 1 03:56:46 2008 | Cross-referenced by PHPXref 0.7 |