GraphAware\Neo4j\OGM\Mapping\AnnotationDriver::readAnnotations PHP Méthode

readAnnotations() public méthode

public readAnnotations ( $class )
    public function readAnnotations($class)
    {
        $reflClass = new \ReflectionClass($class);
        $classAnnotations = $this->reader->getClassAnnotations($reflClass);
        $metadata = ['fields' => [], 'associations' => [], 'relationshipEntities' => []];
        foreach ($classAnnotations as $annotation) {
            if ($annotation instanceof Node) {
                $metadata['type'] = 'Node';
                $metadata['label'] = $annotation->getLabel();
                if ($annotation->hasCustomRepository()) {
                    $metadata['repository'] = $this->getRepositoryFullClassName($annotation->getRepositoryClass(), $class);
                }
            } elseif ($annotation instanceof RelationshipEntity) {
                $metadata['type'] = 'RelationshipEntity';
                $metadata['relType'] = $annotation->type;
            }
        }
        if (!array_key_exists('type', $metadata)) {
            throw new \Exception(sprintf('The class %s is not a valid OGM entity', $class));
        }
        foreach ($reflClass->getProperties() as $property) {
            foreach ($this->reader->getPropertyAnnotations($property) as $propertyAnnotation) {
                if ($propertyAnnotation instanceof Property) {
                    $metadata['fields'][$property->getName()] = $propertyAnnotation;
                } elseif ($propertyAnnotation instanceof Relationship && null !== $propertyAnnotation->getTargetEntity()) {
                    $metadata['associations'][$property->getName()] = $propertyAnnotation;
                } elseif ($propertyAnnotation instanceof Relationship && null === $propertyAnnotation->getTargetEntity()) {
                    $metadata['relationshipEntities'][$property->getName()] = $propertyAnnotation;
                } elseif ($propertyAnnotation instanceof StartNode) {
                    $metadata['start_node'] = $propertyAnnotation;
                    $metadata['start_node_key'] = $property->getName();
                } elseif ($propertyAnnotation instanceof EndNode) {
                    $metadata['end_node'] = $propertyAnnotation;
                    $metadata['end_node_key'] = $property->getName();
                } elseif ($propertyAnnotation instanceof Label) {
                    $metadata['fields'][$property->getName()] = $propertyAnnotation;
                }
            }
        }
        return $metadata;
    }