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,312
14년 전 조회 1,570
14년 전 조회 1,128
14년 전 조회 2,126
14년 전 조회 802
14년 전 조회 812
14년 전 조회 643
14년 전 조회 1,441
14년 전 조회 1,057
14년 전 조회 779
14년 전 조회 5,302
14년 전 조회 1,929
14년 전 조회 1,155
14년 전 조회 656
14년 전 조회 9,456
14년 전 조회 1,568
14년 전 조회 586
14년 전 조회 572
14년 전 조회 1,437
14년 전 조회 2,011
14년 전 조회 1,562
14년 전 조회 818
14년 전 조회 2,063
14년 전 조회 2,071
14년 전 조회 3,014
14년 전 조회 1,113
14년 전 조회 1,307
14년 전 조회 829
14년 전 조회 914
14년 전 조회 2,139
14년 전 조회 931
14년 전 조회 2,398
14년 전 조회 640
14년 전 조회 3,509
14년 전 조회 730
14년 전 조회 2,089
14년 전 조회 3,471
14년 전 조회 780
14년 전 조회 952
14년 전 조회 1,315
14년 전 조회 814
14년 전 조회 1,330
14년 전 조회 1,248
14년 전 조회 1,364
14년 전 조회 1,105
14년 전 조회 741
14년 전 조회 1,208
14년 전 조회 1,193
14년 전 조회 1,067
14년 전 조회 624
14년 전 조회 607
14년 전 조회 951
14년 전 조회 514
14년 전 조회 3,086
14년 전 조회 597
14년 전 조회 960
14년 전 조회 609
14년 전 조회 645
14년 전 조회 1,873
14년 전 조회 926
14년 전 조회 1,405
14년 전 조회 669
14년 전 조회 1,298
14년 전 조회 1,779
14년 전 조회 826
14년 전 조회 1,335
14년 전 조회 830
14년 전 조회 1,195
14년 전 조회 2,623
14년 전 조회 691
14년 전 조회 4,805
14년 전 조회 695
14년 전 조회 885
14년 전 조회 726
14년 전 조회 3,418
14년 전 조회 528
14년 전 조회 861
14년 전 조회 1,159
14년 전 조회 1,155
14년 전 조회 646
14년 전 조회 1,252
14년 전 조회 727
14년 전 조회 619
14년 전 조회 2,275
14년 전 조회 973
14년 전 조회 601
14년 전 조회 597
14년 전 조회 1,624
14년 전 조회 774
14년 전 조회 1,183
14년 전 조회 1,165
14년 전 조회 1,777
14년 전 조회 1,850
14년 전 조회 1,127
14년 전 조회 790
14년 전 조회 723
14년 전 조회 969
14년 전 조회 1,125
14년 전 조회 2,536
14년 전 조회 596
🐛 버그신고