Exemplo n.º 1
0
 public function post_scaffold($table, $database = false)
 {
     //TODO Also create the templates
     if (SITE_STATE == 'production') {
         Backend::addError('Cannot run scaffold on a production site');
         return false;
     }
     if (empty($database)) {
         $db = Backend::getDB('default', true);
     } else {
         $db = Backend::getDB($database, true);
     }
     $database = $db['database'];
     $connection = $db['connection'];
     if (!$connection instanceof PDO) {
         Backend::addError('Could not get Database Connection');
         return false;
     }
     $destination = defined('SITE_FOLDER') ? SITE_FOLDER : APP_FOLDER;
     if (!is_writable($destination . '/controllers') || !is_writable($destination . '/models') || !is_writable($destination . '/templates')) {
         Backend::addError('Destinations aren\'t writable: ' . $destination);
         return false;
     }
     $variables = array('table_name' => $table, 'class_name' => class_name($table), 'db_name' => $database, 'author' => ConfigValue::get('author.Name'), 'company' => ConfigValue::get('author.Company'));
     return Scaffold::generate($variables, $connection, $destination);
 }