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,299
14년 전 조회 1,551
14년 전 조회 1,117
14년 전 조회 2,111
14년 전 조회 787
14년 전 조회 800
14년 전 조회 627
14년 전 조회 1,428
14년 전 조회 1,043
14년 전 조회 765
14년 전 조회 5,294
14년 전 조회 1,908
14년 전 조회 1,144
14년 전 조회 644
14년 전 조회 9,439
14년 전 조회 1,552
14년 전 조회 572
14년 전 조회 554
14년 전 조회 1,422
14년 전 조회 2,000
14년 전 조회 1,548
14년 전 조회 798
14년 전 조회 2,051
14년 전 조회 2,055
14년 전 조회 3,003
14년 전 조회 1,106
14년 전 조회 1,294
14년 전 조회 812
14년 전 조회 900
14년 전 조회 2,122
14년 전 조회 914
14년 전 조회 2,383
14년 전 조회 625
14년 전 조회 3,496
14년 전 조회 718
14년 전 조회 2,075
14년 전 조회 3,461
14년 전 조회 769
14년 전 조회 947
14년 전 조회 1,306
14년 전 조회 804
14년 전 조회 1,312
14년 전 조회 1,240
14년 전 조회 1,351
14년 전 조회 1,097
14년 전 조회 731
14년 전 조회 1,199
14년 전 조회 1,179
14년 전 조회 1,054
14년 전 조회 612
14년 전 조회 592
14년 전 조회 939
14년 전 조회 501
14년 전 조회 3,068
14년 전 조회 583
14년 전 조회 944
14년 전 조회 597
14년 전 조회 626
14년 전 조회 1,861
14년 전 조회 912
14년 전 조회 1,396
14년 전 조회 654
14년 전 조회 1,285
14년 전 조회 1,763
14년 전 조회 807
14년 전 조회 1,323
14년 전 조회 820
14년 전 조회 1,185
14년 전 조회 2,609
14년 전 조회 669
14년 전 조회 4,792
14년 전 조회 679
14년 전 조회 865
14년 전 조회 713
14년 전 조회 3,404
14년 전 조회 514
14년 전 조회 848
14년 전 조회 1,144
14년 전 조회 1,140
14년 전 조회 632
14년 전 조회 1,238
14년 전 조회 719
14년 전 조회 609
14년 전 조회 2,263
14년 전 조회 957
14년 전 조회 585
14년 전 조회 584
14년 전 조회 1,614
14년 전 조회 765
14년 전 조회 1,170
14년 전 조회 1,159
14년 전 조회 1,766
14년 전 조회 1,842
14년 전 조회 1,114
14년 전 조회 779
14년 전 조회 710
14년 전 조회 954
14년 전 조회 1,113
14년 전 조회 2,524
14년 전 조회 584
🐛 버그신고