Development

Changeset 7046

You must first sign up to be able to contribute.

Changeset 7046

Show
Ignore:
Timestamp:
01/14/08 13:25:22 (10 months ago)
Author:
fabien
Message:

implemented all proxy methods in sfWidgetFormSchemaDecorator

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/widget/sfWidgetFormSchemaDecorator.class.php

    r6220 r7046  
    2626   * Constructor. 
    2727   * 
    28    * The decorated widget is cloned. 
    29    * 
    3028   * @param sfWidgetFormSchema A sfWidgetFormSchema instance 
    3129   * @param string             A decorator string 
     
    3533  public function __construct(sfWidgetFormSchema $widget, $decorator) 
    3634  { 
    37     $this->widget    = clone $widget; 
     35    $this->widget    = $widget; 
    3836    $this->decorator = $decorator; 
    3937 
    40     $this->nameFormat     = $widget->getNameFormat(); 
    41     $this->formFormatters = $widget->getFormFormatters(); 
    42     $this->formFormatter  = $widget->getFormFormatterName(); 
    43  
    44     $this->attributes = $widget->getAttributes(); 
    45     $this->options    = $widget->getOptions(); 
    46     $this->labels     = $widget->getLabels(); 
    47     $this->helps      = $widget->getHelps(); 
     38    parent::__construct(); 
     39  } 
     40 
     41  /** 
     42   * Returns the decorated widget. 
     43   * 
     44   * @param sfWidget The decorated widget 
     45   */ 
     46  public function getWidget() 
     47  { 
     48    return $this->widget; 
    4849  } 
    4950 
     
    5354  public function render($name, $values = array(), $attributes = array(), $errors = array()) 
    5455  { 
    55     $this->widget->setNameFormat($this->nameFormat); 
    56     foreach ($this->formFormatters as $name => $formFormatter) 
    57     { 
    58       $this->widget->addFormFormatter($name, $formFormatter); 
    59     } 
    60     $this->widget->setFormFormatterName($this->formFormatter); 
    61  
    62     $this->widget->setAttributes($this->attributes); 
    63     $this->widget->setOptions($this->options); 
    64     $this->widget->setLabels($this->labels); 
    65     $this->widget->setHelps($this->helps); 
    66  
    6756    return strtr($this->decorator, array('%content%' => $this->widget->render($name, $values, $attributes, $errors))); 
    6857  } 
     
    7160   * @see sfWidgetFormSchema 
    7261   */ 
     62  public function addFormFormatter($name, sfWidgetFormSchemaFormatter $formatter) 
     63  { 
     64    return $this->widget->addFormFormatter($name, $formatter); 
     65  } 
     66 
     67  /** 
     68   * @see sfWidgetFormSchema 
     69   */ 
     70  public function getFormFormatters() 
     71  { 
     72    return $this->widget->getFormFormatters(); 
     73  } 
     74 
     75  /** 
     76   * @see sfWidgetFormSchema 
     77   */ 
     78  public function setFormFormatterName($name) 
     79  { 
     80    $this->widget->setFormFormatterName($name); 
     81  } 
     82 
     83  /** 
     84   * @see sfWidgetFormSchema 
     85   */ 
     86  public function getFormFormatterName() 
     87  { 
     88    return $this->widget->getFormFormatterName(); 
     89  } 
     90 
     91  /** 
     92   * @see sfWidgetFormSchema 
     93   */ 
     94  public function getFormFormatter() 
     95  { 
     96    return $this->widget->getFormFormatter(); 
     97  } 
     98 
     99  /** 
     100   * @see sfWidgetFormSchema 
     101   */ 
     102  public function setNameFormat($format) 
     103  { 
     104    $this->widget->setNameFormat($format); 
     105  } 
     106 
     107  /** 
     108   * @see sfWidgetFormSchema 
     109   */ 
     110  public function getNameFormat() 
     111  { 
     112    return $this->widget->getNameFormat(); 
     113  } 
     114 
     115  /** 
     116   * @see sfWidgetFormSchema 
     117   */ 
     118  public function setLabels($labels) 
     119  { 
     120    $this->widget->setLabels($labels); 
     121  } 
     122 
     123  /** 
     124   * @see sfWidgetFormSchema 
     125   */ 
     126  public function getLabels() 
     127  { 
     128    return $this->widget->getLabels(); 
     129  } 
     130 
     131  /** 
     132   * @see sfWidgetFormSchema 
     133   */ 
     134  public function setLabel($name, $value) 
     135  { 
     136    $this->widget->setLabel($name, $value); 
     137  } 
     138 
     139  /** 
     140   * @see sfWidgetFormSchema 
     141   */ 
     142  public function getLabel($name) 
     143  { 
     144    return $this->widget->getLabel($name); 
     145  } 
     146 
     147  /** 
     148   * @see sfWidgetFormSchema 
     149   */ 
     150  public function setHelps($helps) 
     151  { 
     152    $this->widget->setHelps($helps); 
     153  } 
     154 
     155  /** 
     156   * @see sfWidgetFormSchema 
     157   */ 
     158  public function getHelps() 
     159  { 
     160    return $this->widget->getHelps(); 
     161  } 
     162 
     163  /** 
     164   * @see sfWidgetFormSchema 
     165   */ 
     166  public function setHelp($name, $help) 
     167  { 
     168    $this->widget->setHelp($name, $help); 
     169  } 
     170 
     171  /** 
     172   * @see sfWidgetFormSchema 
     173   */ 
     174  public function getHelp($name) 
     175  { 
     176    return $this->widget->getHelp($name); 
     177  } 
     178 
     179  /** 
     180   * @see sfWidgetFormSchema 
     181   */ 
     182  public function needsMultipartForm() 
     183  { 
     184    return $this->widget->needsMultipartForm(); 
     185  } 
     186 
     187  /** 
     188   * @see sfWidgetFormSchema 
     189   */ 
     190  public function renderField($name, $value = null, $errors = array()) 
     191  { 
     192    return $this->widget->renderField($name, $value, $errors); 
     193  } 
     194 
     195  /** 
     196   * @see sfWidgetFormSchema 
     197   */ 
     198  public function generateLabel($name) 
     199  { 
     200    return $this->widget->generateLabel($name); 
     201  } 
     202 
     203  /** 
     204   * @see sfWidgetFormSchema 
     205   */ 
     206  public function generateLabelName($name) 
     207  { 
     208    return $this->widget->generateLabelName($name); 
     209  } 
     210 
     211  /** 
     212   * @see sfWidgetFormSchema 
     213   */ 
     214  public function generateName($name) 
     215  { 
     216    return $this->widget->generateName($name); 
     217  } 
     218 
     219  /** 
     220   * @see sfWidgetFormSchema 
     221   */ 
     222  public function getParent() 
     223  { 
     224    return $this->widget->getParent(); 
     225  } 
     226 
     227  /** 
     228   * @see sfWidgetFormSchema 
     229   */ 
     230  public function setParent(sfWidgetFormSchema $parent) 
     231  { 
     232    $this->widget->setParent($parent); 
     233  } 
     234 
     235  /** 
     236   * @see sfWidgetFormSchema 
     237   */ 
     238  public function getFields() 
     239  { 
     240    return $this->widget->getFields(); 
     241  } 
     242 
     243  /** 
     244   * @see sfWidgetFormSchema 
     245   */ 
     246  public function getPositions() 
     247  { 
     248    return $this->widget->getPositions(); 
     249  } 
     250 
     251  /** 
     252   * @see sfWidgetFormSchema 
     253   */ 
     254  public function setPositions($positions) 
     255  { 
     256    $this->widget->setPositions($positions); 
     257  } 
     258 
     259  /** 
     260   * @see sfWidgetFormSchema 
     261   */ 
     262  public function moveField($field, $action, $pivot = null) 
     263  { 
     264    return $this->widget->moveField($field, $action, $pivot); 
     265  } 
     266 
     267  /** 
     268   * @see sfWidgetFormSchema 
     269   */ 
    73270  public function offsetExists($name) 
    74271  { 
     
    100297  } 
    101298 
    102   /** 
    103    * @see sfWidgetFormSchema 
    104    */ 
    105   public function getFields() 
    106   { 
    107     return $this->widget->getFields(); 
     299  public function __clone() 
     300  { 
     301    $this->widget = clone $this->widget; 
    108302  } 
    109303} 
  • branches/1.1/test/unit/widget/sfWidgetFormSchemaDecoratorTest.php

    r6197 r7046  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(9, new lime_output_color()); 
     13$t = new lime_test(15, new lime_output_color()); 
    1414 
    1515$w1 = new sfWidgetFormInput(); 
     
    1818 
    1919$w = new sfWidgetFormSchemaDecorator($ws, "<table>\n%content%</table>"); 
     20 
     21// ->getWidget() 
     22$t->diag('->getWidget()'); 
     23$t->is($w->getWidget(), $ws, '->getWidget() returns the decorated widget'); 
    2024 
    2125// ->render() 
     
    3539$w['w2'] = $w2; 
    3640$t->is($w->getFields(), array('w1' => $w1, 'w2' => $w2), 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
    37 $t->is($ws->getFields(), array('w1' => $w1), 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     41$t->is($ws->getFields(), array('w1' => $w1, 'w2' => $w2), 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
    3842 
    3943try 
     
    4953$w = new sfWidgetFormSchemaDecorator($ws, "<table>\n%content%</table>"); 
    5054$t->is(isset($w['w1']), true, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
    51 $t->is(isset($w['w2']), false, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     55$t->is(isset($w['w2']), true, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     56$t->is(isset($ws['w1']), true, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     57$t->is(isset($ws['w2']), true, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
    5258 
    5359$w = new sfWidgetFormSchemaDecorator($ws, "<table>\n%content%</table>"); 
    5460$t->is($w['w1'], $w1, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
    55 $t->is($w['w2'], null, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     61$t->is($w['w2'], $w2, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     62$t->is($ws['w1'], $w1, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     63$t->is($ws['w2'], $w2, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
    5664 
    5765$w = new sfWidgetFormSchemaDecorator($ws, "<table>\n%content%</table>"); 
    5866unset($w['w1']); 
    5967$t->is($w['w1'], null, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 
     68$t->is($ws['w1'], null, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields');