Merge branch 'v0.9.5' of https://github.com/alllinux/Nibiru into v0.9.5

This commit is contained in:
Stephan Kasdorf
2021-05-19 19:58:21 +02:00
2 changed files with 41 additions and 3 deletions

View File

@@ -98,7 +98,7 @@ class Model extends Table
$template = str_replace('[FIELDARRAY]', $fieldarray, $this->getModelTemplate()); $template = str_replace('[FIELDARRAY]', $fieldarray, $this->getModelTemplate());
$template = str_replace('[TABLE]', $table, $template); $template = str_replace('[TABLE]', $table, $template);
$template = str_replace('[CLASSNAME]', ucfirst($classname), $template); $template = str_replace('[CLASSNAME]', ucfirst($classname), $template);
$template = str_replace('[FOLDERNAME]', ucfirst($this->getDatabase()), $template); $template = str_replace('[FOLDERNAME]', ucfirst($this->getFolderNamespace()), $template);
$template = str_replace('[DBSECTION]', $this->getConfigSection(), $template); $template = str_replace('[DBSECTION]', $this->getConfigSection(), $template);
if($this->getDatabaseDriver()==self::DB_DRIVER_POSTGRESS) if($this->getDatabaseDriver()==self::DB_DRIVER_POSTGRESS)

View File

@@ -43,6 +43,7 @@ class Table
private $_model_template = ""; private $_model_template = "";
private $_config_section = ""; private $_config_section = "";
private $_database_driver = ""; private $_database_driver = "";
private $_folder_namespace = "";
public function __construct( $argv ) public function __construct( $argv )
{ {
@@ -60,6 +61,7 @@ class Table
$this->_setDatabaseDriver(); $this->_setDatabaseDriver();
$this->_setDatabase(); $this->_setDatabase();
$this->_setDbNamespace(); $this->_setDbNamespace();
$this->_setFolderNamespace();
$this->_setFolderOut(); $this->_setFolderOut();
$this->_setTable(); $this->_setTable();
$this->_setTemplateFile( Config::getInstance()->getConfig()[self::CONFIG_SECTION][self::DB_CONFIG_TEMPLATE] ); $this->_setTemplateFile( Config::getInstance()->getConfig()[self::CONFIG_SECTION][self::DB_CONFIG_TEMPLATE] );
@@ -95,6 +97,41 @@ class Table
} }
} }
/**
* @return string
*/
protected function getFolderNamespace(): string
{
return $this->_folder_namespace;
}
/**
* @desc will convert the folder name to hungarian notation
*/
private function _setFolderNamespace( ): void
{
if(strstr($this->getDatabase(), '-'))
{
$parts = explode('-', $this->getDatabase());
foreach($parts as $part)
{
$this->_folder_namespace .= ucfirst($part);
}
}
if(strstr($this->getDatabase(), '_'))
{
$parts = explode('_', $this->getDatabase());
foreach($parts as $part)
{
$this->_folder_namespace .= ucfirst($part);
}
}
if(!$this->getFolderNamespace())
{
$this->_folder_namespace = $this->getDatabase();
}
}
/** /**
* @return string * @return string
*/ */
@@ -170,13 +207,14 @@ class Table
*/ */
private function _setFolderOut( ) private function _setFolderOut( )
{ {
if(array_key_exists(self::DB_CONFIG_SECTION, $this->getParams())) if(array_key_exists(self::DB_CONFIG_SECTION, $this->getParams()))
{ {
$this->_folder_out = $this->getParams()[self::DB_CONFIG_SECTION_MODEL] . $this->getDatabase(); $this->_folder_out = $this->getParams()[self::DB_CONFIG_SECTION_MODEL] . $this->getFolderNamespace();
} }
else else
{ {
$this->_folder_out = __DIR__ . Config::getInstance()->getConfig()[self::CONFIG_SECTION][self::DB_CONFIG_SECTION_MODEL] . $this->getDatabase(); $this->_folder_out = __DIR__ . Config::getInstance()->getConfig()[self::CONFIG_SECTION][self::DB_CONFIG_SECTION_MODEL] . $this->getFolderNamespace();
} }
} }