Ejemplo n.º 1
0
 /**
  * primarily for tearDown() in unit tests
  */
 public static function __unsetRegistry()
 {
     self::$_registry = null;
 }
Ejemplo n.º 2
0
 /**
  * Initialize the registry. Invoking this method more than once will generate an exception.
  *
  * @param mixed $registry - Either a name of the registry class (Zend_Registry, or a subclass)
  *                          or an instance of Zend_Registry (or subclass)
  *
  * @return Zend_Registry
  */
 public static function initRegistry($registry = 'Zend_Registry')
 {
     // prevent multiple calls to this method
     if (self::$_registry !== null) {
         throw new Zend_Exception(__CLASS__ . '::' . __FUNCTION__ . '()' . '::' . __LINE__ . ' registry already initialized.');
     }
     if ($registry === 'Zend_Registry') {
         require_once 'Zend/Registry.php';
     }
     if (is_string($registry)) {
         if (!class_exists($registry, false)) {
             throw new Zend_Exception(__CLASS__ . '::' . __FUNCTION__ . '()' . '::' . __LINE__ . " {$registry}' class not found.");
         } else {
             self::initRegistry(new $registry());
         }
     } else {
         if (!class_exists('Zend_Registry', false)) {
             require_once 'Zend/Registry.php';
         }
         if (!$registry instanceof Zend_Registry) {
             throw new Zend_Exception(__CLASS__ . '::' . __FUNCTION__ . '()' . '::' . __LINE__ . " {$registry}' is not an \"" . "instanceof\" Zend_Registry (or subclass)");
         }
         self::$_registry = $registry;
     }
     return self::$_registry;
 }