public function getProperties($filter = null) { if (null === $filter) { $filter = \ReflectionProperty::IS_STATIC | \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE; } $properties = array(); foreach (parent::getProperties($filter) as $property) { $properties[] = new ReflectionProperty($property->class, $property->name); } return $properties; }
/** * @param \Hynage\ORM\Entity $entity * @return \Hynage\ORM\EntityManager */ private function addProxies(Entity $entity) { $reflectionClass = new ReflectionClass($entity::getClassNameOfEntityDefinition()); foreach ($reflectionClass->getProperties(\ReflectionMethod::IS_PROTECTED) as $property) { $definition = $property->getAnnotation('HynageRelation'); if (!is_array($definition)) { continue; } $proxy = new Proxy($this, $entity, $definition['class'], $definition['local'], $definition['foreign'], $definition['type']); $entity->setProxy($property->name, $proxy); } return $this; }
/** * @return array */ public static function getFieldDefinitions() { $fields = array(); $reflectionClass = new ReflectionClass(static::getClassNameOfEntityDefinition()); foreach ($reflectionClass->getProperties(\ReflectionMethod::IS_PROTECTED) as $property) { $definition = $property->getAnnotation('HynageColumn'); if (!is_array($definition)) { continue; } $propertyName = $property->name; $name = isset($definition['name']) ? $definition['name'] : ltrim($property->name, '_'); $type = isset($definition['type']) ? strtoupper($definition['type']) : 'VARCHAR'; $length = isset($definition['length']) ? (int) $definition['length'] : null; $attributes = array(); $attributes['unsigned'] = $property->hasAnnotation('HynageColumnUnsigned'); $attributes['notNull'] = $property->hasAnnotation('HynageColumnNotNull'); $attributes['autoIncrement'] = $property->hasAnnotation('HynageColumnAutoIncrement'); $attributes['primary'] = $property->hasAnnotation('HynageColumnPrimary'); if ($property->hasAnnotation('HynageColumnDefault')) { $attributes['default'] = $property->getAnnotation('HynageColumnDefault'); } $fields[] = new Field($name, $propertyName, $type, $length, $attributes); } return $fields; }