v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2778
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,475
12-01-21 조회 2,790
12-01-19 조회 4,808
12-01-18 조회 2,757
12-01-18 조회 2,784
12-01-18 조회 2,990
12-01-17 조회 2,758
12-01-17 조회 2,968
12-01-14 조회 1.1만
12-01-14 조회 3,518
12-01-14 조회 3,828
12-01-11 조회 3,189
12-01-11 조회 3,068
12-01-11 조회 3,004
12-01-11 조회 3,049
12-01-11 조회 3,393
12-01-11 조회 2,588
12-01-10 조회 3,010
12-01-10 조회 2,792
12-01-10 조회 2,800
12-01-09 조회 2,739
12-01-08 조회 2,778
12-01-07 조회 2,775
12-01-06 조회 2,635
12-01-06 조회 2,758
12-01-05 조회 2,753
12-01-02 조회 2,907
11-12-29 조회 2,755
11-12-28 조회 2,759
11-12-28 조회 2,737
11-12-27 조회 2,986
11-12-23 조회 2,686
11-12-23 조회 2,742
11-12-21 조회 3,860
11-12-21 조회 2,847
11-12-19 조회 2,799
11-12-14 조회 4,107
11-12-08 조회 3,180
11-12-08 조회 4,029
11-12-07 조회 4,321
11-12-06 조회 4,222
11-12-06 조회 3,522
11-12-05 조회 3,153
11-12-05 조회 4,790
11-12-04 조회 3,134
11-12-03 조회 3,488
11-12-02 조회 3,358
11-12-02 조회 3,444
11-12-02 조회 2,779
11-12-01 조회 2,746
11-12-01 조회 3,648
11-12-01 조회 2,735
11-11-29 조회 5,623
11-11-23 조회 3,558
11-11-23 조회 3,855
11-11-22 조회 3,877
11-11-22 조회 2,919
11-11-21 조회 3,481
11-11-21 조회 2,767
11-11-18 조회 3,861
11-11-18 조회 3,038
11-11-17 조회 2,931
11-11-17 조회 2,933
11-11-17 조회 4,488
11-11-11 조회 2,796
11-11-11 조회 2,797
11-11-11 조회 3,931
11-11-11 조회 4,613
11-11-08 조회 2,903
11-11-06 조회 3,347
11-11-06 조회 3,637
11-10-21 조회 2,449
11-10-21 조회 2,350
11-10-19 조회 2,401
11-10-19 조회 3,897
11-10-08 조회 2,455
11-10-06 조회 4,136
11-10-01 조회 2,425
11-09-30 조회 2,535
11-09-29 조회 2,539
11-09-26 조회 2,390
11-09-23 조회 2,393
11-09-23 조회 2,168
11-09-22 조회 2,755
11-09-09 조회 3,032
11-08-30 조회 3,920
11-08-23 조회 2,166
11-08-12 조회 2,351
11-08-04 조회 3,942
11-07-01 조회 2,912
11-06-09 조회 2,553
11-05-17 조회 2,603
11-05-07 조회 2,936
11-04-21 조회 2,600
11-04-12 조회 2,432
11-04-11 조회 3,564
11-02-11 조회 2,685
11-02-08 조회 2,101
11-01-11 조회 2,521
10-11-26 조회 3,841