public function loadResourceMap($classes) { $resources = array(); foreach ($classes as $class) { $reflection = new \ReflectionAnnotatedClass($class); $name = ""; if ($reflection->hasAnnotation("Service")) { $annotation = $reflection->getAnnotation('Service'); $resources[$this->getResourceName($annotation, $class)] = $reflection->getName(); } if ($reflection->hasAnnotation("Repository")) { $annotation = $reflection->getAnnotation('Repository'); $resources[$this->getResourceName($annotation, $class)] = $reflection->getName(); } } return $resources; }
private function reflectClass ( $class_name ) { require_once $this->file_name; // reflect class $class = new ReflectionAnnotatedClass( $class_name ); // reflect @DefinitionObject if ( $class_annotation = $class->getAnnotation( 'DefinitionObject' ) ) { // set table $table = new DefinitionObject; $table->table = $class_annotation->table; $this->setTable( $class->getName(), $table ); unset( $table ); if ( isset( $class_annotation->build ) && $class_annotation->build ) { $this->build = $class_annotation->build; } // iterate properties foreach ( $class->getProperties() as $property ) { $ref_col = $property->getAnnotation( 'DefinitionObject' ); // create column $column = new DefinitionObject; $column->column = $ref_col->column; $column->type = $ref_col->type; $column->size = $ref_col->size; $column->scale = $ref_col->scale; $column->default = $ref_col->default; $column->required = $ref_col->required; $column->autoIncrement = $ref_col->autoIncrement; $column->primaryKey = $ref_col->primaryKey; $column->index = $ref_col->index; $column->unique = $ref_col->unique; // reflect @ReferenceDef if ( $ref_ref = $property->getAnnotation( 'ReferenceDef' ) ) { // create reference $ref = new ReferenceDef(); $ref->table = $ref_ref->table; $ref->column = $ref_ref->column; $ref->onUpdate = $ref_ref->onUpdate; $ref->onDelete = $ref_ref->onDelete; } // set column string $this->setColumn( $property->getName(), $column, isset( $ref ) ? $ref : false ); unset( $ref ); unset( $column ); } } }
/** * {@inheritdoc} */ public function matches($className, \ReflectionAnnotatedClass $reflection) { return preg_match('/' . $this->expression . '/', $reflection->getName()); }
public function __construct($nome, $cpf, $idade, $senha, $ativo) { $classe = new ReflectionAnnotatedClass($type); $this->type = $classe->getName(); $this->setTableName(); }