Registry
[ class tree: Registry ] [ index: Registry ] [ all elements ]

Source for file Registry.php

Documentation is available at Registry.php

  1. <?php
  2. /**
  3.  * MVClasses
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * @category    MVClasses
  14.  * @package     Registry
  15.  * @copyright   Copyright (c) 2007 Sven Strittmatter
  16.  */
  17.  
  18. /**
  19.  * Enter description here...
  20.  *
  21.  * Longdesc
  22.  *
  23.  * @todo complete description
  24.  *
  25.  * @category    MVClasses
  26.  * @package     Registry
  27.  * @copyright     Copyright (c) 2007 Sven Strittmatter
  28.  * @author    "Sven Strittmatter" <ausserirdisch@sven-space.de>
  29.  * @version     1.0
  30.  * @link        http://www.sven-space.de/code/php/MVClasses
  31.  */
  32. class Registry {
  33.     const KEY_REQUEST "request";
  34.     const KEY_RESPONSE "response";
  35.  
  36.     protected static $_instance;
  37.     protected $_values;
  38.  
  39.     protected function __construct({
  40.         $this->_values = array();
  41.     }
  42.  
  43.     public function setRequest(Request $r{
  44.         $this->_set(self::KEY_REQUEST$r);
  45.     }
  46.  
  47.     public function getRequest({
  48.         return $this->_get(self::KEY_REQUEST);
  49.     }
  50.  
  51.     public function setResponse(Response $r{
  52.         $this->_set(self::KEY_RESPONSE$r);
  53.     }
  54.  
  55.     public function retResponse({
  56.         return $this->_get(self::KEY_RESPONSE);
  57.     }
  58.  
  59.     public static function getInstance({
  60.         if (null === self::$_instance{
  61.             self::$_instance new Registry();
  62.         }
  63.  
  64.         return self::$_instance;
  65.     }
  66.  
  67.     protected function _set($key$value{
  68.         $this->_values[$key$value;
  69.     }
  70.  
  71.     protected function _get($key{
  72.         if (isset($this->_values[$key])) {
  73.             return $this->_values[$key];
  74.         }
  75.  
  76.         return null;
  77.     }
  78.  
  79.     protected function __clone({}
  80. }

Documentation generated on Sun, 02 Aug 2009 17:15:02 +0200 by phpDocumentor 1.4.2