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,292
14년 전 조회 1,543
14년 전 조회 1,108
14년 전 조회 2,100
14년 전 조회 777
14년 전 조회 793
14년 전 조회 619
14년 전 조회 1,420
14년 전 조회 1,034
14년 전 조회 756
14년 전 조회 5,285
14년 전 조회 1,901
14년 전 조회 1,137
14년 전 조회 636
14년 전 조회 9,430
14년 전 조회 1,545
14년 전 조회 563
14년 전 조회 546
14년 전 조회 1,415
14년 전 조회 1,991
14년 전 조회 1,542
14년 전 조회 793
14년 전 조회 2,040
14년 전 조회 2,044
14년 전 조회 2,996
14년 전 조회 1,097
14년 전 조회 1,288
14년 전 조회 804
14년 전 조회 893
14년 전 조회 2,113
14년 전 조회 902
14년 전 조회 2,376
14년 전 조회 619
14년 전 조회 3,490
14년 전 조회 711
14년 전 조회 2,062
14년 전 조회 3,450
14년 전 조회 760
14년 전 조회 939
14년 전 조회 1,299
14년 전 조회 797
14년 전 조회 1,302
14년 전 조회 1,231
14년 전 조회 1,343
14년 전 조회 1,091
14년 전 조회 723
14년 전 조회 1,194
14년 전 조회 1,167
14년 전 조회 1,045
14년 전 조회 601
14년 전 조회 583
14년 전 조회 931
14년 전 조회 495
14년 전 조회 3,061
14년 전 조회 573
14년 전 조회 936
14년 전 조회 589
14년 전 조회 617
14년 전 조회 1,850
14년 전 조회 906
14년 전 조회 1,386
14년 전 조회 644
14년 전 조회 1,276
14년 전 조회 1,754
14년 전 조회 794
14년 전 조회 1,315
14년 전 조회 808
14년 전 조회 1,175
14년 전 조회 2,598
14년 전 조회 660
14년 전 조회 4,782
14년 전 조회 673
14년 전 조회 857
14년 전 조회 703
14년 전 조회 3,390
14년 전 조회 506
14년 전 조회 836
14년 전 조회 1,133
14년 전 조회 1,132
14년 전 조회 625
14년 전 조회 1,230
14년 전 조회 711
14년 전 조회 598
14년 전 조회 2,251
14년 전 조회 949
14년 전 조회 574
14년 전 조회 574
14년 전 조회 1,603
14년 전 조회 754
14년 전 조회 1,161
14년 전 조회 1,153
14년 전 조회 1,756
14년 전 조회 1,833
14년 전 조회 1,105
14년 전 조회 765
14년 전 조회 697
14년 전 조회 948
14년 전 조회 1,101
14년 전 조회 2,513
14년 전 조회 571
🐛 버그신고