Development

#3499: getWidgetClassForColumn.diff

You must first sign up to be able to contribute.

Ticket #3499: getWidgetClassForColumn.diff

File getWidgetClassForColumn.diff, 3.2 kB (added by thomas.s, 2 months ago)

remove the naming collision between column name and widget class name

  • plugins/sfDoctrinePlugin/lib/generator/sfDoctrineFormGenerator.class.php

    old new  
    246246   * 
    247247   * @return string    The name of a subclass of sfWidgetForm 
    248248   */ 
    249   public function getWidgetClassForColumn($name) 
     249  public function getWidgetClassForColumn($columnName) 
    250250  { 
    251     $column = $this->table->getDefinitionOf($name); 
     251    $column = $this->table->getDefinitionOf($columnName); 
    252252    switch ($column['type']) 
    253253    { 
    254254      case 'boolean': 
    255         $name = 'InputCheckbox'; 
     255        $widgetSubclass = 'InputCheckbox'; 
    256256        break; 
    257257      case 'glob': 
    258258      case 'clob': 
    259         $name = 'Textarea'; 
     259        $widgetSubclass = 'Textarea'; 
    260260        break; 
    261261      case 'date': 
    262         $name = 'Date'; 
     262        $widgetSubclass = 'Date'; 
    263263        break; 
    264264      case 'time': 
    265         $name = 'Time'; 
     265        $widgetSubclass = 'Time'; 
    266266        break; 
    267267      case 'timestamp': 
    268         $name = 'DateTime'; 
     268        $widgetSubclass = 'DateTime'; 
    269269        break; 
    270270      default: 
    271         $name = 'Input'; 
     271        $widgetSubclass = 'Input'; 
    272272    } 
    273273 
    274274 
    275     if ($this->isColumnPrimaryKey($name)) 
     275    if ($this->isColumnPrimaryKey($columnName)) 
    276276    { 
    277       $name = 'InputHidden'; 
     277      $widgetSubclass = 'InputHidden'; 
    278278    } 
    279     else if ($this->isColumnForeignKey($name)) 
     279    else if ($this->isColumnForeignKey($columnName)) 
    280280    { 
    281       $name = 'DoctrineSelect'; 
     281      $widgetSubclass = 'DoctrineSelect'; 
    282282    } 
    283283 
    284     return sprintf('sfWidgetForm%s', $name); 
     284    return sprintf('sfWidgetForm%s', $widgetSubclass); 
    285285  } 
    286286 
    287287  /** 
     
    372372   * 
    373373   * @return string    The name of a subclass of sfValidator 
    374374   */ 
    375   public function getValidatorClassForColumn($colName) 
     375  public function getValidatorClassForColumn($columnName) 
    376376  { 
    377     $column = $this->table->getDefinitionOf($colName); 
     377    $column = $this->table->getDefinitionOf($columnName); 
    378378    switch ($column['type']) 
    379379    { 
    380380      case 'boolean': 
    381         $name = 'Boolean'; 
     381        $validatorSubclass = 'Boolean'; 
    382382        break; 
    383383      case 'string': 
    384384      case 'clob': 
    385385      case 'glob': 
    386         $name = 'String'; 
     386        $validatorSubclass = 'String'; 
    387387        break; 
    388388      case 'float': 
    389389      case 'decimal': 
    390390      case 'integer': 
    391         $name = 'Number'; 
     391        $validatorSubclass = 'Number'; 
    392392        break; 
    393393      case 'integer': 
    394         $name = 'Integer'; 
     394        $validatorSubclass = 'Integer'; 
    395395        break; 
    396396      case 'date': 
    397         $name = 'Date'; 
     397        $validatorSubclass = 'Date'; 
    398398        break; 
    399399      case 'time': 
    400         $name = 'Time'; 
     400        $validatorSubclass = 'Time'; 
    401401        break; 
    402402      case 'timestamp': 
    403         $name = 'DateTime'; 
     403        $validatorSubclass = 'DateTime'; 
    404404        break; 
    405405      default: 
    406         $name = 'Pass'; 
     406        $validatorSubclass = 'Pass'; 
    407407    } 
    408408 
    409     if ($this->isColumnPrimaryKey($colName) || $this->isColumnForeignKey($colName)) 
     409    if ($this->isColumnPrimaryKey($columnName) || $this->isColumnForeignKey($columnName)) 
    410410    { 
    411       $name = 'DoctrineChoice'; 
     411      $validatorSubclass = 'DoctrineChoice'; 
    412412    } 
    413413 
    414     return sprintf('sfValidator%s', $name); 
     414    return sprintf('sfValidator%s', $validatorSubclass); 
    415415  } 
    416416 
    417417  /**