Source for file basicconfigreadersingleton_php5.php

Documentation is available at basicconfigreadersingleton_php5.php

  1. <?php
  2. /**
  3. * Generic configuration management object
  4. *
  5. * Parses the {@link bumblebee.ini } file
  6. *
  7. * @author    Stuart Prescott
  8. * @copyright  Copyright Stuart Prescott
  9. * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10. * @version    $Id: basicconfigreadersingleton_php5.php,v 1.1 2007/02/16 23:10:22 themill Exp $
  11. * @package    Bumblebee
  12. * @subpackage Misc
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18.  
  19.   function BasicConfigReaderSingleton() {
  20.     static $constructed = false;
  21.     #echo "Constructor called";
  22.         if ($constructed) {
  23.       trigger_error('ConfigReader is a singleton. Instantiate it only once if you must (and you must instantiate it once if you want to inherit it) and then use getInstance()', E_USER_ERROR);
  24.     }
  25.     BasicConfigReader::_instanceManager($this);
  26.     $constructed = true;
  27.   }
  28.  
  29.   static function & getInstance() {
  30.     return BasicConfigReader::_instanceManager();
  31.   }
  32.  
  33.   static function & _instanceManager($newInstance = null) {
  34.     static $instance = array();
  35.  
  36.     if ($newInstance == null) {
  37.       if (count($instance) < 1 || $instance[0] == null) {
  38.         #echo "Making instance";
  39.                 $instance[0] = new BasicConfigReader();
  40.       }
  41.       #echo "Returning instance";
  42.             return $instance[0];
  43.     } else {
  44.       #echo "registering instance";
  45.             $instance[0] = & $newInstance;
  46.       return $instance[0];
  47.     }
  48.   }
  49.  
  50. }
  51.  
  52. ?>

Documentation generated on Tue, 06 Mar 2007 10:00:40 +0000 by phpDocumentor 1.3.0