Changeset 5035

Show
Ignore:
Timestamp:
10/02/08 09:13:11 (3 months ago)
Author:
jwage
Message:

[1.1] fixes #1522 Added support for custom setters with fromArray()

Location:
branches/1.1
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/1.1/lib/Doctrine/Record.php

    r5034 r5035  
    15281528            } else if ($this->getTable()->hasField($key)) { 
    15291529                $this->set($key, $value); 
     1530            } else { 
     1531                $method = 'set' . Doctrine_Inflector::classify($key); 
     1532                if (method_exists($this, $method)) { 
     1533                    $this->$method($value); 
     1534                } 
    15301535            } 
    15311536        } 
  • branches/1.1/tests/Record/FromArrayTestCase.php

    r4610 r5035  
    8686        $this->assertEqual($user->Group[1]->name, 'Group One'); 
    8787    } 
    88  
    8988} 
  • branches/1.1/tests/run.php

    r5034 r5035  
    153153$tickets->addTestCase(new Doctrine_Ticket_1480_TestCase()); 
    154154$tickets->addTestCase(new Doctrine_Ticket_1507_TestCase()); 
     155$tickets->addTestCase(new Doctrine_Ticket_1522_TestCase()); 
    155156$test->addTestCase($tickets); 
    156157 
  • branches/1.1/UPGRADE_TO_1_1

    r5034 r5035  
    5656    ) 
    5757    */ 
     58 
     59[r5035](http://trac.doctrine-project.org/changeset/5035) - Added ability to use custom setters with fromArray() 
     60 
     61    public function setTableDefinition() 
     62    { 
     63        $this->hasColumn('password'); 
     64    } 
     65 
     66    public function setEncryptedPassword($password) 
     67    { 
     68        return $this->_set('password', md5($password)); 
     69    } 
     70 
     71    $user->fromArray(array('encrypted_password' => 'changeme')); 
     72 
     73Will invoke the custom setter setEncryptedPassword() 
    5874 
    5975Default Options