public static function fromClass(AnnotationReader $reader, $className) { $class = new \ReflectionClass($className); if ($class->implementsInterface('HireVoice\\Neo4j\\EntityProxy')) { $class = $class->getParentClass(); $className = $class->getName(); } if (!($entity = $reader->getClassAnnotation($class, 'HireVoice\\Neo4j\\Annotation\\Entity'))) { throw new Exception("Class {$className} is not declared as an entity."); } $object = new self($class->getName()); if ($entity->repositoryClass) { $object->repositoryClass = $entity->repositoryClass; } foreach ($class->getProperties() as $property) { $prop = new PropertyMeta($reader, $property); if ($prop->isPrimaryKey()) { $object->setPrimaryKey($prop); } elseif ($prop->isProperty($prop)) { $object->properties[] = $prop; if ($prop->isIndexed()) { $object->indexedProperties[] = $prop; } } elseif ($prop->isRelationList()) { $object->manyToManyRelations[] = $prop; } elseif ($prop->isRelation()) { $object->manyToOneRelations[] = $prop; } } $object->validate(); return $object; }