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,632
14년 전 조회 1,880
14년 전 조회 1,408
14년 전 조회 2,463
14년 전 조회 1,095
14년 전 조회 1,091
14년 전 조회 929
14년 전 조회 1,744
14년 전 조회 1,358
14년 전 조회 1,082
14년 전 조회 5,661
14년 전 조회 2,232
14년 전 조회 1,504
14년 전 조회 933
14년 전 조회 9,730
14년 전 조회 1,859
14년 전 조회 883
14년 전 조회 874
14년 전 조회 1,797
14년 전 조회 2,295
14년 전 조회 1,841
14년 전 조회 1,097
14년 전 조회 2,375
14년 전 조회 2,383
14년 전 조회 3,347
14년 전 조회 1,437
14년 전 조회 1,580
14년 전 조회 1,114
14년 전 조회 1,214
14년 전 조회 2,449
14년 전 조회 1,219
14년 전 조회 2,707
14년 전 조회 916
14년 전 조회 3,795
14년 전 조회 1,029
14년 전 조회 2,378
14년 전 조회 3,773
14년 전 조회 1,052
14년 전 조회 1,247
14년 전 조회 1,615
14년 전 조회 1,115
14년 전 조회 1,632
14년 전 조회 1,537
14년 전 조회 1,656
14년 전 조회 1,425
14년 전 조회 1,026
14년 전 조회 1,505
14년 전 조회 1,513
14년 전 조회 1,352
14년 전 조회 924
14년 전 조회 869
14년 전 조회 1,292
14년 전 조회 804
14년 전 조회 3,374
14년 전 조회 867
14년 전 조회 1,229
14년 전 조회 879
14년 전 조회 939
14년 전 조회 2,176
14년 전 조회 1,196
14년 전 조회 1,714
14년 전 조회 946
14년 전 조회 1,537
14년 전 조회 2,045
14년 전 조회 1,099
14년 전 조회 1,590
14년 전 조회 1,095
14년 전 조회 1,485
14년 전 조회 2,910
14년 전 조회 962
14년 전 조회 5,154
14년 전 조회 956
14년 전 조회 1,146
14년 전 조회 976
14년 전 조회 3,702
14년 전 조회 777
14년 전 조회 1,138
14년 전 조회 1,428
14년 전 조회 1,436
14년 전 조회 897
14년 전 조회 1,528
14년 전 조회 992
14년 전 조회 873
14년 전 조회 2,552
14년 전 조회 1,260
14년 전 조회 867
14년 전 조회 859
14년 전 조회 1,873
14년 전 조회 1,060
14년 전 조회 1,471
14년 전 조회 1,463
14년 전 조회 2,087
14년 전 조회 2,119
14년 전 조회 1,404
14년 전 조회 1,028
14년 전 조회 965
14년 전 조회 1,204
14년 전 조회 1,379
14년 전 조회 2,881
14년 전 조회 849