예제 #1
0
 /**
  * Destroy singletons to force reconstruction
  */
 function _destroy()
 {
     // destroy class map factory
     include_once EP_SRC_ORM . '/epClassMap.php';
     epClassMapFactory::destroy();
     // destroy db connections
     include_once EP_SRC_DB . '/epDbObject.php';
     epDbFactory::destroy();
     // destroy manager
     include_once EP_SRC_RUNTIME . '/epManager.php';
     epManager::destroy();
 }
예제 #2
0
 /**
  * Initialization
  * @param bool $force whether to force initialization
  * @return bool
  * @throws epExceptionManagerBase
  */
 protected function initialize($force = false)
 {
     // done if not forced, and class map and db factories are set
     if (!$force && $this->cmf && $this->dbf) {
         return true;
     }
     // load compiled info into manager
     if (!$this->_loadCompiled()) {
         return false;
     }
     // get the db factory
     include_once EP_SRC_DB . '/epDbObject.php';
     if (!($this->dbf =& epDbFactory::instance())) {
         throw new epExceptionManagerBase('Cannot get db factory instance');
         return false;
     }
     // remove all connections
     $this->dbf->removeAll();
     // set the db lib to use
     $this->dbf->setDbLib($this->getConfigOption('db_lib'));
     // set up class autoloading if 'autoload' is set to true
     if ($this->getConfigOption('autoload')) {
         if (function_exists('epSetupAutoload')) {
             epSetupAutoload();
         }
     }
     // register auto flush as the shutdown function
     if ($this->getConfigOption('auto_flush')) {
         register_shutdown_function(array($this, 'flushAll'));
     }
     return true;
 }
예제 #3
0
 /**
  * Initialization
  * @param bool $force whether to force initialization
  * @return bool
  * @throws epExceptionManagerBase
  */
 protected function initialize($force = false)
 {
     // done if not forced, and class map and db factories are set
     if (!$force && $this->cmf && $this->dbf) {
         return true;
     }
     // get the runtime class map file
     if (!($rcmf = $this->getConfigOption('compiled_file'))) {
         throw new epExceptionManagerBase('Runtime class map file not specified');
         return false;
     }
     // get the dir that holds the class map file
     if ($compiled_dir = $this->getConfigOption('compiled_dir')) {
         // if compiled dir is a relative path, make is absolute
         $compiled_dir = $this->getAbsolutePath($compiled_dir);
         $rcmf = $compiled_dir . '/' . $rcmf;
     }
     // check if force_compile is set
     if ($this->getConfigOption('force_compile')) {
         // if so, delete the compiled file to force compile
         if (file_exists($rcmf)) {
             @unlink($rcmf);
         }
     }
     // unserializing class map file into class map factory
     include_once EP_SRC_ORM . '/epClassMap.php';
     // get the contetns of the runtime config map file
     $runtime_map_content = false;
     if (file_exists($rcmf)) {
         $runtime_map_content = file_get_contents($rcmf);
     }
     // if compiled runtime map content exists and config file is older than compiled
     if ($runtime_map_content && filemtime($this->getConfigSource()) < filemtime($rcmf)) {
         // unserialize class map info
         $this->cmf =& epClassMapFactory::unserialize($runtime_map_content);
         if (!$this->cmf) {
             throw new epExceptionManagerBase('Cannot unserialize runtime class mapping info');
             return false;
         }
         // need to recompile new class files
         $this->_compileAll();
     } else {
         // if no compiled class map file found, simply get the class map factory instance
         $this->cmf =& epClassMapFactory::instance();
         // remove all classes now
         $this->cmf->removeAll();
         // check if the source dir is set
         if ($source_dirs = $this->getConfigOption('source_dirs')) {
             // compile all if so
             $this->_compileAll();
         }
     }
     // get the db factory
     include_once EP_SRC_DB . '/epDbObject.php';
     if (!($this->dbf =& epDbFactory::instance())) {
         throw new epExceptionManagerBase('Cannot get db factory instance');
         return false;
     }
     // remove all connections
     $this->dbf->removeAll();
     // set the db lib to use
     $this->dbf->setDbLib($this->getConfigOption('db_lib'));
     return true;
 }
예제 #4
0
 /**
  * Implement {@link epSingleton} interface
  * Forcefully destroy old instance (only used for tests). 
  * After reset(), {@link instance()} returns a new instance.
  */
 public static function destroy()
 {
     if (self::$instance) {
         self::$instance->removeAll();
     }
     self::$instance = null;
 }
예제 #5
0
 /**
  * Implement {@link epSingleton} interface
  * Forcefully destroy old instance (only used for tests). 
  * After reset(), {@link instance()} returns a new instance.
  */
 public static function destroy()
 {
     self::$instance = null;
 }