v

PHP ANOTATION , Reflection

· 14년 전 · 1200
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,890
14년 전 조회 2,148
14년 전 조회 1,682
14년 전 조회 2,712
14년 전 조회 1,332
14년 전 조회 1,349
14년 전 조회 1,205
14년 전 조회 2,010
14년 전 조회 1,639
14년 전 조회 1,346
14년 전 조회 5,958
14년 전 조회 2,483
14년 전 조회 1,791
14년 전 조회 1,222
14년 전 조회 9,978
14년 전 조회 2,152
14년 전 조회 1,132
14년 전 조회 1,148
14년 전 조회 2,089
14년 전 조회 2,567
14년 전 조회 2,104
14년 전 조회 1,349
14년 전 조회 2,640
14년 전 조회 2,623
14년 전 조회 3,639
14년 전 조회 1,723
14년 전 조회 1,822
14년 전 조회 1,353
14년 전 조회 1,471
14년 전 조회 2,716
14년 전 조회 1,480
14년 전 조회 2,987
14년 전 조회 1,184
14년 전 조회 4,056
14년 전 조회 1,274
14년 전 조회 2,633
14년 전 조회 4,038
14년 전 조회 1,312
14년 전 조회 1,491
14년 전 조회 1,870
14년 전 조회 1,363
14년 전 조회 1,897
14년 전 조회 1,804
14년 전 조회 1,900
14년 전 조회 1,725
14년 전 조회 1,260
14년 전 조회 1,756
14년 전 조회 1,750
14년 전 조회 1,618
14년 전 조회 1,201
14년 전 조회 1,120
14년 전 조회 1,586
14년 전 조회 1,048
14년 전 조회 3,628
14년 전 조회 1,077
14년 전 조회 1,466
14년 전 조회 1,103
14년 전 조회 1,148
14년 전 조회 2,393
14년 전 조회 1,442
14년 전 조회 1,914
14년 전 조회 1,176
14년 전 조회 1,742
14년 전 조회 2,282
14년 전 조회 1,330
14년 전 조회 1,796
14년 전 조회 1,333
14년 전 조회 1,696
14년 전 조회 3,131
14년 전 조회 1,185
14년 전 조회 5,397
14년 전 조회 1,179
14년 전 조회 1,361
14년 전 조회 1,199
14년 전 조회 3,922
14년 전 조회 995
14년 전 조회 1,340
14년 전 조회 1,628
14년 전 조회 1,649
14년 전 조회 1,113
14년 전 조회 1,744
14년 전 조회 1,209
14년 전 조회 1,086
14년 전 조회 2,755
14년 전 조회 1,492
14년 전 조회 1,092
14년 전 조회 1,067
14년 전 조회 2,119
14년 전 조회 1,284
14년 전 조회 1,690
14년 전 조회 1,671
14년 전 조회 2,326
14년 전 조회 2,346
14년 전 조회 1,616
14년 전 조회 1,238
14년 전 조회 1,198
14년 전 조회 1,411
14년 전 조회 1,592
14년 전 조회 3,122
14년 전 조회 1,056