Changeset 4436 for trunk/lib/Doctrine
- Timestamp:
- 05/25/08 21:57:32 (8 months ago)
- Location:
- trunk/lib/Doctrine
- Files:
-
- 3 modified
-
ClassMetadata.php (modified) (1 diff)
-
Entity.php (modified) (5 diffs)
-
EntityManager.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/ClassMetadata.php
r4429 r4436 952 952 $columnName = $this->getColumnName($fieldName); 953 953 return isset($this->_mappedColumns[$columnName]['mutator']) ? 954 $this->_mappedColumns[$columnName]['mutator'] : null;954 $this->_mappedColumns[$columnName]['mutator'] : null; 955 955 } 956 956 -
trunk/lib/Doctrine/Entity.php
r4417 r4436 249 249 //-- 250 250 251 self::$_useAutoAccessorOverride = false; // @todo read from attribute the first time251 self::$_useAutoAccessorOverride = true; // @todo read from attribute the first time 252 252 } 253 253 … … 995 995 public function get($fieldName, $load = false) 996 996 { 997 if ($getter = $this->_getCustomAccessor($fieldName)) { 998 return $this->$getter(); 999 } 997 1000 $this->_invokeCustomAccessor($fieldName); 998 1001 … … 1028 1031 } 1029 1032 1030 private function _invokeCustomAccessor($fieldName) 1033 private function _getCustomMutator($fieldName) 1034 { 1035 if ( ! isset(self::$_mutatorCache[$this->_entityName][$fieldName])) { 1036 if (self::$_useAutoAccessorOverride) { 1037 $setterMethod = 'set' . Doctrine::classify($fieldName); 1038 if (method_exists($this, $setterMethod)) { 1039 self::$_mutatorCache[$this->_entityName][$fieldName] = $setterMethod; 1040 } else { 1041 self::$_mutatorCache[$this->_entityName][$fieldName] = false; 1042 } 1043 } 1044 1045 if ($setter = $this->_class->getCustomMutator($fieldName)) { 1046 self::$_mutatorCache[$this->_entityName][$fieldName] = $setter; 1047 } else if ( ! isset(self::$_mutatorCache[$this->_entityName][$fieldName])) { 1048 self::$_mutatorCache[$this->_entityName][$fieldName] = false; 1049 } 1050 } 1051 1052 return self::$_mutatorCache[$this->_entityName][$fieldName]; 1053 } 1054 1055 private function _getCustomAccessor($fieldName) 1031 1056 { 1032 1057 if ( ! isset(self::$_accessorCache[$this->_entityName][$fieldName])) { … … 1045 1070 } 1046 1071 } 1047 // invoke custom accessor, if it exists. 1048 if ($getter = self::$_accessorCache[$this->_entityName][$fieldName]) { 1049 return $this->$getter(); 1050 } 1072 1073 return self::$_accessorCache[$this->_entityName][$fieldName]; 1051 1074 } 1052 1075 … … 1071 1094 */ 1072 1095 public function set($fieldName, $value, $load = false) 1073 { 1096 { 1097 if ($setter = $this->_getCustomMutator($fieldName)) { 1098 return $this->$setter($value); 1099 } 1100 1074 1101 if ($this->_class->hasField($fieldName)) { 1075 1102 if ($value instanceof Doctrine_Entity) { -
trunk/lib/Doctrine/EntityManager.php
r4375 r4436 20 20 */ 21 21 22 #namespace Doctrine::ORM; 23 22 24 /** 23 25 * The EntityManager is a central access point to ORM functionality.