v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2843
PHP 에서도 anotation 드리븐을 구현 할 수 있을거 같내요 ㅎ;
 
잘만 활용 하면, spring framework 장점만 경량화 하여
 php 진영에서도 ... framework 도 나오지 않을가 하는
생각을 문득 해봤습니다.
 
------------------------------------------------------------------
 
 
/** @Table("people") */ 
class Person { 
   
// some code 
}
 
$reflection = new ReflectionAnnotatedClass('Person'); // by class name 
$reflection
->getAnnotation('Table')->value; // contains string "people"
 
----------------------------------------------------------------------
 
class RolesAllowed extends Annotation {} 
 
/** @RolesAllowed({'admin', 'web-editor'}) */ 
class CMS { 
 
// some code 
} 
 
$reflection
= new ReflectionAnnotatedClass('CMS'); 
$annotation
= $reflection->getAnnotation('RolesAllowed'); 
$annotation
->value; // contains array('admin', 'web-editor'
 
 
-------------------------------------------------------------
 
/** @Mapping(inheritance = @SingleTableInheritance, columns = {@ColumnMapping('id'), @ColumnMapping('name')}) */ 
class Person {} 
 
$reflection
= new ReflectionAnnotatedClass('Person'); 
$annotation
= $reflection->getAnnotation('Mapping'); 
$annotation
->inheritance; // SingleTableInheritance annotation 
$annotation
->columns; // array of ColumnMapping annotations 
$annotation
->columns[0]->value; // 'id'
 
 
 
 
 
 
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-03-02 조회 3,229
16-01-19 조회 2,512
15-12-23 조회 2,883
15-12-08 조회 3,638
14-10-30 조회 5,697
14-06-06 조회 5,527
12-08-30 조회 3,883
12-08-20 조회 3,808
12-07-15 조회 5,142
12-07-13 조회 3,619
12-07-06 조회 3,836
12-06-27 조회 3,355
12-06-23 조회 3,548
12-05-03 조회 5,169
12-04-20 조회 4,106
12-03-29 조회 4,600
12-03-22 조회 4,692
12-03-22 조회 3,492
12-03-21 조회 3,270
12-03-11 조회 3,694
12-03-06 조회 4,244
12-02-22 조회 4,511
12-02-17 조회 3,317
12-02-17 조회 6,163
12-02-14 조회 6,105
12-02-06 조회 4,242
12-01-18 조회 3,206
12-01-06 조회 3,427
11-12-30 조회 3,892
11-12-30 조회 7,041
11-12-21 조회 3,256
11-12-21 조회 4,229
11-12-16 조회 3,259
11-12-15 조회 3,306
11-12-15 조회 3,405
11-12-15 조회 4,206
11-12-09 조회 3,216
11-12-09 조회 3,294
11-12-07 조회 2,859
11-12-07 조회 3,947
11-12-05 조회 4,400
11-12-02 조회 3,847
11-12-01 조회 2,716
11-12-01 조회 2,756
11-12-01 조회 2,738