Changeset 4852

Show
Ignore:
Timestamp:
08/27/08 20:26:49 (10 months ago)
Author:
jwage
Message:

fixes #1077

Location:
branches/1.0
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine.php

    r4847 r4852  
    196196    const ATTR_RECURSIVE_MERGE_FIXTURES = 162; 
    197197    const ATTR_USE_DQL_CALLBACKS        = 164; 
     198    const ATTR_AUTO_ACCESSOR_OVERRIDE   = 165; 
    198199 
    199200    /** 
  • branches/1.0/lib/Doctrine/Configurable.php

    r4682 r4852  
    182182            case Doctrine::ATTR_RECURSIVE_MERGE_FIXTURES; 
    183183            case Doctrine::ATTR_USE_DQL_CALLBACKS; 
     184            case Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE; 
    184185 
    185186                break; 
  • branches/1.0/lib/Doctrine/Manager.php

    r4845 r4852  
    103103                        Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES   => false, 
    104104                        Doctrine::ATTR_USE_DQL_CALLBACKS        => false, 
     105                        Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE   => false, 
    105106                        );  
    106107            foreach ($attributes as $attribute => $value) { 
  • branches/1.0/lib/Doctrine/Record.php

    r4826 r4852  
    139139 
    140140    /** 
     141     * Array of custom accessors for cache 
     142     * 
     143     * @var array 
     144     */ 
     145    protected static $_customAccessors = array(); 
     146 
     147    /** 
     148     * Array of custom mutators for cache 
     149     * 
     150     * @var array 
     151     */ 
     152    protected static $_customMutators = array(); 
     153 
     154    /** 
    141155     * @var integer $index                  this index is used for creating object identifiers 
    142156     */ 
     
    893907    public function get($fieldName, $load = true) 
    894908    { 
     909        if ($this->_table->getAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE)) { 
     910            $componentName = $this->_table->getComponentName(); 
     911            $accessor = isset(self::$_customAccessors[$componentName][$fieldName]) ? self::$_customAccessors[$componentName][$fieldName]:'get' . Doctrine_Inflector::classify($fieldName); 
     912            if (isset(self::$_customAccessors[$componentName][$fieldName]) || method_exists($this, $accessor)) { 
     913                self::$_customAccessors[$componentName][$fieldName] = $accessor; 
     914                return $this->$accessor($load); 
     915            } 
     916        } 
     917        return $this->_get($fieldName, $load); 
     918    } 
     919 
     920    protected function _get($fieldName, $load = true) 
     921    { 
    895922        $value = self::$_null; 
    896923 
     
    960987     */ 
    961988    public function set($fieldName, $value, $load = true) 
     989    { 
     990        if ($this->_table->getAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE)) { 
     991            $componentName = $this->_table->getComponentName(); 
     992            $mutator = isset(self::$_customMutators[$componentName][$fieldName]) ? self::$_customMutators[$componentName][$fieldName]:'set' . Doctrine_Inflector::classify($fieldName); 
     993            if (isset(self::$_customMutators[$componentName][$fieldName]) || method_exists($this, $mutator)) { 
     994                self::$_customMutators[$componentName][$fieldName] = $mutator; 
     995                return $this->$mutator($value, $load); 
     996            } 
     997        } 
     998        return $this->_set($fieldName, $value, $load); 
     999    } 
     1000 
     1001    protected function _set($fieldName, $value, $load = true) 
    9621002    { 
    9631003        if (isset($this->_data[$fieldName])) { 
  • branches/1.0/tests/run.php

    r4845 r4852  
    8282$tickets->addTestCase(new Doctrine_Ticket_1071_TestCase()); 
    8383$tickets->addTestCase(new Doctrine_Ticket_1072_TestCase()); 
     84$tickets->addTestCase(new Doctrine_Ticket_1077_TestCase()); 
    8485$tickets->addTestCase(new Doctrine_Ticket_1099_TestCase()); 
    8586$tickets->addTestCase(new Doctrine_Ticket_1106_TestCase());