toArray(); } /* * Convert Zend_Config argument to plain string * adapter name and separate config object. */ if ($adapter instanceof Zend_Config) { if (isset($adapter->params)) { $config = $adapter->params->toArray(); } if (isset($adapter->adapter)) { $adapter = (string) $adapter->adapter; } else { $adapter = null; } } /* * Verify that adapter parameters are in an array. */ if (!is_array($config)) { throw new DbException('Adapter parameters must be in an array or a Zend_Config object'); } /* * Verify that an adapter name has been specified. */ if (!is_string($adapter) || empty($adapter)) { throw new DbException('Adapter name must be specified in a string'); } /* * Form full adapter class name */ $adapterClass = '\\gipfl\\ZfDb\\Adapter\\' . str_replace(' ', '\\', ucwords(str_replace('_', ' ', strtolower($adapter)))); $dbAdapter = new $adapterClass($config); /* * Verify that the object created is a descendent of the abstract adapter type. */ if (! $dbAdapter instanceof Adapter) { throw new DbException("Adapter class '$adapterClass' does not extend gipfl\ZfDb\Abstract"); } return $dbAdapter; } }