v

PHP ANOTATION , Reflection

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'
 
 
 
 
 
 
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,516
14년 전 조회 1,772
14년 전 조회 1,299
14년 전 조회 2,360
14년 전 조회 985
14년 전 조회 979
14년 전 조회 829
14년 전 조회 1,636
14년 전 조회 1,247
14년 전 조회 988
14년 전 조회 5,538
14년 전 조회 2,129
14년 전 조회 1,398
14년 전 조회 832
14년 전 조회 9,627
14년 전 조회 1,752
14년 전 조회 766
14년 전 조회 758
14년 전 조회 1,684
14년 전 조회 2,195
14년 전 조회 1,723
14년 전 조회 986
14년 전 조회 2,276
14년 전 조회 2,286
14년 전 조회 3,245
14년 전 조회 1,326
14년 전 조회 1,474
14년 전 조회 1,001
14년 전 조회 1,109
14년 전 조회 2,345
14년 전 조회 1,119
14년 전 조회 2,595
14년 전 조회 813
14년 전 조회 3,702
14년 전 조회 914
14년 전 조회 2,272
14년 전 조회 3,661
14년 전 조회 945
14년 전 조회 1,147
14년 전 조회 1,521
14년 전 조회 1,001
14년 전 조회 1,537
14년 전 조회 1,436
14년 전 조회 1,537
14년 전 조회 1,319
14년 전 조회 917
14년 전 조회 1,386
14년 전 조회 1,391
14년 전 조회 1,251
14년 전 조회 825
14년 전 조회 763
14년 전 조회 1,171
14년 전 조회 699
14년 전 조회 3,270
14년 전 조회 782
14년 전 조회 1,142
14년 전 조회 789
14년 전 조회 848
14년 전 조회 2,083
14년 전 조회 1,103
14년 전 조회 1,620
14년 전 조회 857
14년 전 조회 1,443
14년 전 조회 1,945
14년 전 조회 998
14년 전 조회 1,502
14년 전 조회 1,009
14년 전 조회 1,393
14년 전 조회 2,816
14년 전 조회 876
14년 전 조회 5,048
14년 전 조회 862
14년 전 조회 1,055
14년 전 조회 882
14년 전 조회 3,625
14년 전 조회 678
14년 전 조회 1,054
14년 전 조회 1,331
14년 전 조회 1,331
14년 전 조회 808
14년 전 조회 1,438
14년 전 조회 910
14년 전 조회 780
14년 전 조회 2,456
14년 전 조회 1,164
14년 전 조회 776
14년 전 조회 753
14년 전 조회 1,794
14년 전 조회 972
14년 전 조회 1,361
14년 전 조회 1,343
14년 전 조회 2,007
14년 전 조회 2,029
14년 전 조회 1,307
14년 전 조회 949
14년 전 조회 883
14년 전 조회 1,112
14년 전 조회 1,306
14년 전 조회 2,775
14년 전 조회 764