/** * * @param type $bundlename * @param type $tables * @param type $update */ public function __construct($bundlename, $tables = array(), $update = 0) { $dir = $bundlename . "Bundle"; $this->name = $bundlename; $this->namespace = "CMS\\" . $dir; $dir = $_SERVER["DOCUMENT_ROOT"] . "\\" . $dir; if (!file_exists($dir)) { mkdir($dir, 0755); foreach ($tables as $nome => $campi) { if (is_array($campi) && !Tab::exists($nome)) { $result = Tab::create($nome, $campi); } else { $result = true; } if ($result) { $this->createController($nome); $this->createEntity($nome); } } } else { if ($update == 1) { foreach ($tables as $name) { $keys = Config::getDB()->getAllKeys($name); $creator = new EntityCreator($name, $keys, "", $this->name); $creator->updateFromDatabase(); if (!file_exists($_SERVER["DOCUMENT_ROOT"] . "\\" . $this->name . "Bundle" . "\\Controller\\" . $name . "Controller")) { $this->createController($name); } } } if ($update == 2) { foreach ($tables as $name) { $keys = Config::getDB()->getAllKeys($name); $creator = new EntityCreator($name, $keys, "", $this->name); $creator->updateToDatabase(); } } } }
/** * */ private function getDbContents() { if (Table::exists($this->name)) { $names = Config::getDB()->GetColumnNames($this->name); foreach ($names as $chiave => $nome) { $valori_var = $this->getDbVarInfoByDB($nome); $field_tmp = new Field($valori_var["type"]); $field_tmp->setNullable($valori_var["nullable"]); $field_tmp->setDefault($valori_var["default"]); $field_tmp->setName($nome); if ($valori_var["key"]) { $field_tmp->setKey($valori_var["key"]); } $field_tmp->setExtra($valori_var["extra"]); $this->fieldsindb[$nome] = $field_tmp; } } }
/** * Creates a bundle */ public static function createBundle($bundlename = "Data", $tables = array()) { $dirname = $_SERVER["DOCUMENT_ROOT"] . "\\" . $bundlename . "Bundle"; if (!file_exists($dirname)) { mkdir($dirname, 0755); } if (count($tables) > 0) { foreach ($tables as $key => $val) { if (\CMS\DbWorkers\Table::exists($val)) { \CMS\Conf\Config::createBundle($bundlename, $tables); } } } }