v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2783
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건
+
제목 글쓴이 날짜 조회
12-01-22 조회 3,485
12-01-21 조회 2,792
12-01-19 조회 4,810
12-01-18 조회 2,775
12-01-18 조회 2,786
12-01-18 조회 2,992
12-01-17 조회 2,761
12-01-17 조회 2,986
12-01-14 조회 1.1만
12-01-14 조회 3,547
12-01-14 조회 3,857
12-01-11 조회 3,207
12-01-11 조회 3,070
12-01-11 조회 3,026
12-01-11 조회 3,058
12-01-11 조회 3,403
12-01-11 조회 2,614
12-01-10 조회 3,017
12-01-10 조회 2,802
12-01-10 조회 2,803
12-01-09 조회 2,755
12-01-08 조회 2,798
12-01-07 조회 2,778
12-01-06 조회 2,638
12-01-06 조회 2,758
12-01-05 조회 2,762
12-01-02 조회 2,910
11-12-29 조회 2,777
11-12-28 조회 2,777
11-12-28 조회 2,759
11-12-27 조회 2,989
11-12-23 조회 2,706
11-12-23 조회 2,745
11-12-21 조회 3,862
11-12-21 조회 2,858
11-12-19 조회 2,799
11-12-14 조회 4,129
11-12-08 조회 3,198
11-12-08 조회 4,030
11-12-07 조회 4,322
11-12-06 조회 4,223
11-12-06 조회 3,539
11-12-05 조회 3,176
11-12-05 조회 4,805
11-12-04 조회 3,136
11-12-03 조회 3,506
11-12-02 조회 3,359
11-12-02 조회 3,445
11-12-02 조회 2,784
11-12-01 조회 2,748
11-12-01 조회 3,652
11-12-01 조회 2,738
11-11-29 조회 5,624
11-11-23 조회 3,561
11-11-23 조회 3,872
11-11-22 조회 3,879
11-11-22 조회 2,937
11-11-21 조회 3,486
11-11-21 조회 2,769
11-11-18 조회 3,864
11-11-18 조회 3,039
11-11-17 조회 2,933
11-11-17 조회 2,933
11-11-17 조회 4,499
11-11-11 조회 2,796
11-11-11 조회 2,797
11-11-11 조회 3,933
11-11-11 조회 4,631
11-11-08 조회 2,904
11-11-06 조회 3,348
11-11-06 조회 3,639
11-10-21 조회 2,450
11-10-21 조회 2,352
11-10-19 조회 2,402
11-10-19 조회 3,901
11-10-08 조회 2,458
11-10-06 조회 4,136
11-10-01 조회 2,445
11-09-30 조회 2,539
11-09-29 조회 2,541
11-09-26 조회 2,396
11-09-23 조회 2,394
11-09-23 조회 2,171
11-09-22 조회 2,755
11-09-09 조회 3,038
11-08-30 조회 3,924
11-08-23 조회 2,181
11-08-12 조회 2,356
11-08-04 조회 3,944
11-07-01 조회 2,915
11-06-09 조회 2,553
11-05-17 조회 2,622
11-05-07 조회 2,937
11-04-21 조회 2,604
11-04-12 조회 2,446
11-04-11 조회 3,565
11-02-11 조회 2,697
11-02-08 조회 2,117
11-01-11 조회 2,521
10-11-26 조회 3,872