public function execute($params, $options = array()) { if (count($params) > 0) { foreach ($params as $table) { $this->_checkAndInstall($table); } } else { $g = new DB_DataObject_Advgenerator(); $generators = $g->getGenerators(); foreach ($generators as $agenerator) { foreach ($agenerator->tables as $table) { $this->_checkAndInstall($table); } } } }
public function executeRegen($params) { $this->line('Regenerating models'); $generator = new DB_DataObject_Advgenerator(); $generator->start(); $this->line('Models need to be reloaded so ...'); $this->launch('reboot'); }
public function execute($params, $options = array()) { if (count($params) > 0) { $this->_checkForCustomLinks(); foreach ($params as $table) { $do = DB_DataObject::factory($table); if (PEAR::isError($do)) { $this->error('Table problem with ' . $table . ' : ' . $do->getMessage()); continue; } $defs = $do->_getPluginsDef(); if (key_exists('guid', $defs)) { $this->_removeGuidFromTable($table); } else { $this->line($table . ' dont have guid installed. IGNORED'); } } } else { if (!$this->confirm('You are about to uninstall guid on the whole project! ARE YOU SURE ?')) { echo 'Aborting'; return; } $this->_checkForCustomLinks(); $g = new DB_DataObject_Advgenerator(); $generators = $g->getGenerators(); $officepacktables = array(); // First loop : creating new primary key. foreach ($generators as $agenerator) { foreach ($agenerator->tables as $table) { $this->line('Checking guid value for ' . $table); $d = DB_DataObject::factory($table); $defs = $d->_getPluginsDef(); if (key_exists('guid', $defs)) { $this->line($table . ' has guid plugin. Uninstalling it....'); $this->_removeGuidFromTable($table); } } } } // Regenerating modified tables /* $options = &PEAR::getStaticProperty('DB_DataObject', 'options'); $oldoption = $options['generator_include_regex']; $options['generator_include_regex'] = '`^('.explode('|',$this->toRegenerate).')$`';*/ if (!$options['noregen']) { $this->line('regenerating models'); $generator = new DB_DataObject_Advgenerator(); $generator->start(); /* $options['generator_include_regex'] = $oldoption;*/ // Removing guid plugin to the DO file foreach ($this->toRemove as $table) { $this->line('removing plugin guid for table ' . $table); $data = file_get_contents(APP_ROOT . 'models/' . ucfirst($table) . '.php'); $data = ereg_replace('(\'|")guid(\'|")[[:space:]]*=>[[:space:]]*(true|1),*', '', $data); file_put_contents(APP_ROOT . 'models/' . ucfirst($table) . '.php', $data); } } }
public function migration_rebuildObjects($obj, $iname) { $options =& PEAR::getStaticProperty('DB_DataObject', 'options'); $options['generator_include_regex'] = '`^(' . $obj->tableName() . '|' . $iname . ')$`'; $generator = new DB_DataObject_Advgenerator(); $generator->start(); return true; }
/** * Used for framework tests development */ public function doExecInitFrameworkDOs() { $options =& PEAR::getStaticProperty('DB_DataObject', 'options'); $options['database'] = DB_URI_TEST; $options['class_location'] = PEAR_FOLDER . 'M/tests/DO/'; $options['schema_location'] = PEAR_FOLDER . 'M/tests/DO/'; ini_set('display_errors', 1); if (!defined('SIMPLE_TEST')) { define('SIMPLE_TEST', 'simpletest/'); } require_once SIMPLE_TEST . 'unit_tester.php'; require_once TESTS_FOLDER . '/extensions/DBTestCase.php'; $t = new DBTestCase(); $t->setUpDatabase('Mfixture.sql', 1); require_once 'M/DB/DataObject/Advgenerator.php'; $generator = new DB_DataObject_Advgenerator(); $generator->start(); $this->redirect(array('module' => 'unittests'), array(), array_keys($_REQUEST)); }