public static function create()
{
$dialectClass = Config::getValue('sql_dialect');
if (!$dialectClass) {
throw new Exception('SQL dialect was not found in config. Please, check for option - sql_dialect.');
}
$dialectClass = new $dialectClass();
if (!$dialectClass instanceof Dialect) {
throw new Exception('Invalid sql_dialect. Dialect have to extend Dialect class.');
}
return $dialectClass;
}
/** * @throws GeneratorException * @return Dialect */ public function dialectAdapter() { $dialect = DialectFactory::create(); $dialectShortName = $this->objectShortClassName($dialect); $selfClassPath = $this->thisNamespace(); $generatorDialect = "{$selfClassPath}\\Dialect\\{$dialectShortName}"; if (!class_exists($generatorDialect)) { throw new GeneratorException("Model generator for '{$dialectShortName}' does not exists."); } return new $generatorDialect($this->tableName); }