-
-
Save doctrinebot/dc6614ca813b2c141e6b to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-248 - https://github.com/doctrine/doctrine2/issues/3198
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- doctrine/lib/Doctrine/ORM/Mapping/ClassMetadata.php (r7029) Fri Jan 15 12:26:13 2010 | |
+++ doctrine/lib/Doctrine/ORM/Mapping/ClassMetadata.php (working copy) Fri Jan 15 12:13:29 2010 | |
@@ -359,16 +359,42 @@ | |
// Restore ReflectionClass and properties | |
$this->reflClass = new \ReflectionClass($this->name); | |
foreach ($this->fieldNames as $field) { | |
- $this->reflFields[$field] = $this->reflClass->getProperty($field); | |
+ $this->reflFields[$field] = $this->_getReflectionProperty($this->reflClass, $field); | |
$this->reflFields[$field]->setAccessible(true); | |
} | |
foreach ($this->associationMappings as $field => $mapping) { | |
- $this->reflFields[$field] = $this->reflClass->getProperty($field); | |
+ $this->reflFields[$field] = $this->_getReflectionProperty($this->reflClass, $field); | |
$this->reflFields[$field]->setAccessible(true); | |
} | |
//$this->prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name)); | |
} | |
+ /** | |
+ * Gets a reflection property for a class. | |
+ * @param \ReflectionClass $refClass | |
+ * @param string $field | |
+ * @return \ReflectionProperty | |
+ */ | |
+ private function _getReflectionProperty(\ReflectionClass $refClass, $field) | |
+ { | |
+ if(!$refClass->hasProperty($field)) | |
+ { | |
+ return NULL; | |
+ } | |
+ foreach($refClass->getProperties() as $p) | |
+ { | |
+ if($p->getName() == $field) | |
+ { | |
+ return $p; | |
+ } | |
+ } | |
+ if($parent = $refClass->getParentClass()) | |
+ { | |
+ return $this->_getReflectionProperty($parent, $field); | |
+ } | |
+ return NULL; | |
+ } | |
+ | |
//public $prototype; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment