/** * Creates a controller and the table associated * @param string $bundlename bundle name * @param string $name controller/table name * @param array $values values */ public static function createController($bundlename, $name, $values) { $res = \CMS\DbWorkers\Table::create($name, $values); if ($res) { self::createBundle($bundlename, array($name)); } #$dirname = $_SERVER["DOCUMENT_ROOT"]."\\".$bundlename."Bundle"; }
/** * * @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(); } } } }