Beispiel #1
0
 /**
  * Create a new data interface ot get an existing one.
  *
  * @param string $inName Name of the interface to create or to get.
  * @param array|null $inOptConfig Optional configuration.
  *        Configuration parameters are:
  *
  *        Mandatory (these parameters may also be set by using mutators):
  *          EntryPointOption::SQL_REPO_PATH
  *          EntryPointOption::SQL_BASE_NS
  *          EntryPointOption::PROC_REPO_PATH
  *          EntryPointOption::PROC_BASE_NS
  *          DocOption::SCHEMA_PATH
  *
  *        Optional:
  *          EntryPointOption::DB_HANDLER (used only when the application is running)
  *
  * @return DatabaseInterface The method returns a new data interface.
  *
  * @see EntryPointOption::SQL_REPO_PATH
  * @see EntryPointOption::SQL_BASE_NS
  * @see EntryPointOption::PROC_REPO_PATH
  * @see EntryPointOption::PROC_BASE_NS
  * @see DocOption::SCHEMA_PATH
  * @see EntryPointOption::DB_HANDLER
  * @see setDbHandler
  */
 public static function getInstance($inName = 'default', array $inOptConfig = null)
 {
     if (array_key_exists($inName, self::$__interfacesRepository)) {
         return self::$__interfacesRepository[$inName];
     }
     $di = new DatabaseInterface($inName);
     // This also create an entry point provider.
     if (!is_null($inOptConfig)) {
         // The following lines configure the entry point provider.
         $di->setSqlRepositoryBasePath($inOptConfig[EntryPointOption::SQL_REPO_PATH]);
         $di->setSqlBaseNameSpace($inOptConfig[EntryPointOption::SQL_BASE_NS]);
         $di->setProcedureRepositoryBasePath($inOptConfig[EntryPointOption::PROC_REPO_PATH]);
         $di->setProcedureBaseNameSpace($inOptConfig[EntryPointOption::PROC_BASE_NS]);
         $di->setPhpDatabaseRepresentationPath($inOptConfig[DocOption::SCHEMA_PATH]);
         if (array_key_exists(EntryPointOption::DB_HANDLER, $inOptConfig)) {
             /** @var mixed $c */
             $c = $inOptConfig[EntryPointOption::DB_HANDLER];
             $di->setDbHandler($c);
         }
     }
     self::$__interfacesRepository[$inName] = $di;
     return self::$__interfacesRepository[$inName];
 }