Ejemplo n.º 1
0
 /**
  * Configures the Piece_ORM environment.
  *
  * First this method tries to load a configuration from a configuration
  * file in the given configration directory using
  * Piece_ORM_Config_Factory::factory(). The method creates a new object
  * if the load failed.
  * Second this method sets the configuration to the current context.
  * And also this method sets the configuration directory for the mapper
  * configuration, and the cache directory for mappers, and the cache
  * directory for Piece_ORM_Metadata class.
  *
  * @param string $configDirectory
  * @param string $cacheDirectory
  * @param string $mapperConfigDirectory
  */
 function configure($configDirectory, $cacheDirectory, $mapperConfigDirectory)
 {
     $config =& Piece_ORM_Config_Factory::factory($configDirectory, $cacheDirectory);
     $context =& Piece_ORM_Context::singleton();
     $context->setConfiguration($config);
     $context->setMapperConfigDirectory($mapperConfigDirectory);
     $defaultDatabase = $config->getDefaultDatabase();
     if (!is_null($defaultDatabase)) {
         $context->setDatabase($defaultDatabase);
     }
     Piece_ORM_Mapper_Factory::setCacheDirectory($cacheDirectory);
     Piece_ORM_Metadata_Factory::setCacheDirectory($cacheDirectory);
     $GLOBALS['PIECE_ORM_Configured'] = true;
 }