Doctrine\ODM\CouchDB\Mapping\ClassMetadata::wakeupReflection PHP Method

wakeupReflection() public method

Restores some state that can not be serialized/unserialized.
public wakeupReflection ( $reflService )
    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;
        }
    }

Usage Example

Exemplo n.º 1
0
 public function getClassMetadata($class)
 {
     $metadata = new \Doctrine\ODM\CouchDB\Mapping\ClassMetadata($class);
     $metadata->initializeReflection(new RuntimeReflectionService());
     $metadata->wakeupReflection(new RuntimeReflectionService());
     return $metadata;
 }
All Usage Examples Of Doctrine\ODM\CouchDB\Mapping\ClassMetadata::wakeupReflection