Exemplo n.º 1
0
 public function testPluralVariable()
 {
     $this->assertEquals('my_vars', StringFormat::pluralVariable('myVar'));
     $this->assertEquals('my_vars', StringFormat::pluralVariable('my--var'));
     $this->assertEquals('my_vars', StringFormat::pluralVariable('my  var'));
     $this->assertEquals('my_vars', StringFormat::pluralVariable('my %^&*  var'));
     $this->assertEquals('my_vars', StringFormat::pluralVariable('my____ var--'));
     $this->assertEquals('my_vars', StringFormat::pluralVariable('my/ \\var'));
 }
Exemplo n.º 2
0
 function getTemplateParams($table_name)
 {
     $class_name = $this->getModelName($table_name);
     $column_names = $PKs = array();
     $auto_increment = false;
     $columns = $this->getColumns($table_name);
     $pks = $this->getPrimaryKeys($table_name);
     $pk = null;
     foreach ($columns as &$column) {
         $column_names[] = $column->getName();
         if ($column->isPrimaryKey()) {
             $PKs[] = $column->getName();
             if ($column->isAutoIncrement()) {
                 $auto_increment = true;
             }
         }
     }
     if (count($PKs) == 1) {
         $pk = $PKs[0];
     } else {
         $auto_increment = false;
     }
     return array('auto_increment' => $auto_increment, 'table_name' => $table_name, 'controller_name' => $this->getControllerName($table_name), 'model_name' => $class_name, 'column_names' => $column_names, 'plural' => StringFormat::pluralVariable($table_name), 'plural_url' => StringFormat::pluralURL($table_name), 'single' => StringFormat::variable($table_name), 'single_url' => StringFormat::url($table_name), 'pk' => $pk, 'primary_keys' => $pks, 'pk_method' => $pk ? StringFormat::classMethod('get' . StringFormat::titleCase($pk)) : null, 'pk_var' => $pk ? StringFormat::variable($pk) : null, 'actions' => $this->getActions($table_name), 'columns' => $columns);
 }