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,302
14년 전 조회 1,562
14년 전 조회 1,121
14년 전 조회 2,118
14년 전 조회 792
14년 전 조회 801
14년 전 조회 630
14년 전 조회 1,436
14년 전 조회 1,050
14년 전 조회 767
14년 전 조회 5,296
14년 전 조회 1,912
14년 전 조회 1,147
14년 전 조회 649
14년 전 조회 9,442
14년 전 조회 1,560
14년 전 조회 577
14년 전 조회 560
14년 전 조회 1,428
14년 전 조회 2,006
14년 전 조회 1,553
14년 전 조회 805
14년 전 조회 2,053
14년 전 조회 2,062
14년 전 조회 3,004
14년 전 조회 1,110
14년 전 조회 1,297
14년 전 조회 819
14년 전 조회 906
14년 전 조회 2,128
14년 전 조회 920
14년 전 조회 2,386
14년 전 조회 631
14년 전 조회 3,501
14년 전 조회 722
14년 전 조회 2,078
14년 전 조회 3,463
14년 전 조회 775
14년 전 조회 947
14년 전 조회 1,311
14년 전 조회 808
14년 전 조회 1,320
14년 전 조회 1,241
14년 전 조회 1,356
14년 전 조회 1,100
14년 전 조회 735
14년 전 조회 1,202
14년 전 조회 1,185
14년 전 조회 1,060
14년 전 조회 615
14년 전 조회 597
14년 전 조회 943
14년 전 조회 507
14년 전 조회 3,075
14년 전 조회 588
14년 전 조회 952
14년 전 조회 601
14년 전 조회 629
14년 전 조회 1,863
14년 전 조회 919
14년 전 조회 1,399
14년 전 조회 661
14년 전 조회 1,289
14년 전 조회 1,771
14년 전 조회 813
14년 전 조회 1,329
14년 전 조회 825
14년 전 조회 1,188
14년 전 조회 2,615
14년 전 조회 674
14년 전 조회 4,799
14년 전 조회 685
14년 전 조회 872
14년 전 조회 718
14년 전 조회 3,410
14년 전 조회 518
14년 전 조회 852
14년 전 조회 1,147
14년 전 조회 1,147
14년 전 조회 639
14년 전 조회 1,244
14년 전 조회 722
14년 전 조회 615
14년 전 조회 2,266
14년 전 조회 962
14년 전 조회 592
14년 전 조회 590
14년 전 조회 1,616
14년 전 조회 768
14년 전 조회 1,174
14년 전 조회 1,161
14년 전 조회 1,769
14년 전 조회 1,846
14년 전 조회 1,122
14년 전 조회 783
14년 전 조회 712
14년 전 조회 960
14년 전 조회 1,118
14년 전 조회 2,529
14년 전 조회 588
🐛 버그신고