public function wakeupReflection($reflService)
{
// Restore ReflectionClass and properties
$this->reflClass = $reflService->getClass($this->name);
$this->namespace = $reflService->getClassNamespace($this->name);
$this->instantiator = $this->instantiator ?: new Instantiator();
foreach ($this->fieldMappings as $field => $mapping) {
if (isset($mapping['declared'])) {
$reflField = new \ReflectionProperty($mapping['declared'], $field);
} else {
$reflField = $this->reflClass->getProperty($field);
}
$reflField->setAccessible(true);
$this->reflFields[$field] = $reflField;
}
foreach ($this->associationsMappings as $field => $mapping) {
if (isset($mapping['declared'])) {
$reflField = new \ReflectionProperty($mapping['declared'], $field);
} else {
$reflField = $this->reflClass->getProperty($field);
}
$reflField->setAccessible(true);
$this->reflFields[$field] = $reflField;
}
if ($this->hasAttachments) {
if ($this->attachmentDeclaredClass) {
$reflField = new \ReflectionProperty($this->attachmentDeclaredClass, $this->attachmentField);
} else {
$reflField = $this->reflClass->getProperty($this->attachmentField);
}
$reflField->setAccessible(true);
$this->reflFields[$this->attachmentField] = $reflField;
}
}