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,293
14년 전 조회 1,543
14년 전 조회 1,110
14년 전 조회 2,101
14년 전 조회 780
14년 전 조회 795
14년 전 조회 621
14년 전 조회 1,420
14년 전 조회 1,035
14년 전 조회 758
14년 전 조회 5,288
14년 전 조회 1,902
14년 전 조회 1,138
14년 전 조회 638
14년 전 조회 9,432
14년 전 조회 1,545
14년 전 조회 565
14년 전 조회 546
14년 전 조회 1,415
14년 전 조회 1,993
14년 전 조회 1,543
14년 전 조회 793
14년 전 조회 2,042
14년 전 조회 2,047
14년 전 조회 2,998
14년 전 조회 1,098
14년 전 조회 1,288
14년 전 조회 805
14년 전 조회 893
14년 전 조회 2,115
14년 전 조회 902
14년 전 조회 2,376
14년 전 조회 620
14년 전 조회 3,490
14년 전 조회 713
14년 전 조회 2,063
14년 전 조회 3,451
14년 전 조회 762
14년 전 조회 940
14년 전 조회 1,299
14년 전 조회 799
14년 전 조회 1,303
14년 전 조회 1,233
14년 전 조회 1,344
14년 전 조회 1,092
14년 전 조회 725
14년 전 조회 1,194
14년 전 조회 1,170
14년 전 조회 1,047
14년 전 조회 605
14년 전 조회 584
14년 전 조회 933
14년 전 조회 496
14년 전 조회 3,063
14년 전 조회 573
14년 전 조회 938
14년 전 조회 590
14년 전 조회 619
14년 전 조회 1,851
14년 전 조회 907
14년 전 조회 1,388
14년 전 조회 646
14년 전 조회 1,279
14년 전 조회 1,754
14년 전 조회 801
14년 전 조회 1,318
14년 전 조회 812
14년 전 조회 1,179
14년 전 조회 2,601
14년 전 조회 660
14년 전 조회 4,785
14년 전 조회 674
14년 전 조회 860
14년 전 조회 707
14년 전 조회 3,396
14년 전 조회 507
14년 전 조회 840
14년 전 조회 1,135
14년 전 조회 1,134
14년 전 조회 629
14년 전 조회 1,231
14년 전 조회 711
14년 전 조회 602
14년 전 조회 2,254
14년 전 조회 953
14년 전 조회 579
14년 전 조회 578
14년 전 조회 1,606
14년 전 조회 756
14년 전 조회 1,161
14년 전 조회 1,154
14년 전 조회 1,759
14년 전 조회 1,833
14년 전 조회 1,105
14년 전 조회 770
14년 전 조회 703
14년 전 조회 948
14년 전 조회 1,104
14년 전 조회 2,516
14년 전 조회 576
🐛 버그신고