Changeset 912
- Timestamp:
- 09/12/07 12:50:22 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/rdbms/persistence/finder/stubDatabaseFinderResult.php
r881 r912 22 22 * reflection class for entity 23 23 * 24 * @var stub ReflectionClass24 * @var stubBaseReflectionClass 25 25 */ 26 protected $ refClass;26 protected $entityClass; 27 27 /** 28 28 * the result set from the database query … … 47 47 * constructor 48 48 * 49 * @param stub ReflectionClass $refClassreflection class for entity50 * @param array $result result set from the database query51 * @param stubSetterMethodHelper $setterMethodHelper list of setter methods for entity52 * @param array $arguments optional list of arguments for entity constructor49 * @param stubBaseReflectionClass $entityClass reflection class for entity 50 * @param array $result result set from the database query 51 * @param stubSetterMethodHelper $setterMethodHelper list of setter methods for entity 52 * @param array $arguments optional list of arguments for entity constructor 53 53 */ 54 public function __construct(stub ReflectionClass $refClass, array $result, stubSetterMethodHelper $setterMethodHelper, array $arguments = null)54 public function __construct(stubBaseReflectionClass $entityClass, array $result, stubSetterMethodHelper $setterMethodHelper, array $arguments = null) 55 55 { 56 $this-> refClass = $refClass;56 $this->entityClass = $entityClass; 57 57 $this->resultIterator = new ArrayIterator($result); 58 58 $this->setterMethodHelper = $setterMethodHelper; … … 63 63 * returns reflection class for entity 64 64 * 65 * @return stub ReflectionClass65 * @return stubBaseReflectionClass 66 66 */ 67 67 public function forClass() 68 68 { 69 return $this-> refClass;69 return $this->entityClass; 70 70 } 71 71 … … 87 87 { 88 88 try { 89 if (null === $this->arguments) { 90 $entity = $this->refClass->newInstance(); 91 } else { 92 $entity = $this->refClass->newInstanceArgs($this->arguments); 93 } 89 $entity = ((null === $this->arguments) ? ($this->entityClass->newInstance()) : ($this->entityClass->newInstanceArgs($this->arguments))); 94 90 } catch (ReflectionException $re) { 95 throw new stubDatabaseFinderException('Can not create a new instance of ' . $this-> refClass->getFullQualifiedClassName(), $re);91 throw new stubDatabaseFinderException('Can not create a new instance of ' . $this->entityClass->getFullQualifiedClassName(), $re); 96 92 } 97 93 98 94 if (null === $entity) { 99 throw new stubDatabaseFinderException('Can not create a new instance of ' . $this-> refClass->getFullQualifiedClassName());95 throw new stubDatabaseFinderException('Can not create a new instance of ' . $this->entityClass->getFullQualifiedClassName()); 100 96 } 101 97 102 98 $this->setterMethodHelper->applySetterMethods($entity, $this->resultIterator->current()); 103 if ($entity instanceof stubPersistable) {104 $entity->setPersistent(true);105 }106 107 99 return $entity; 108 100 }
