PHP ANOTATION , Reflection 입니다.

· 10년 전 · 1007

PHP 에서도 anotation 드리븐을 구현 할 수 있을거 같내요 ㅎ;
 
http://code.google.com/p/addendum/
 
 
 
잘만 활용 하면, 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'

|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
10년 전 조회 978
10년 전 조회 942
10년 전 조회 985
10년 전 조회 1,092
10년 전 조회 960
10년 전 조회 935
10년 전 조회 962
10년 전 조회 1,057
10년 전 조회 967
10년 전 조회 924
10년 전 조회 939
10년 전 조회 956
10년 전 조회 893
10년 전 조회 900
10년 전 조회 1,198
10년 전 조회 1,276
10년 전 조회 1,238
10년 전 조회 925
10년 전 조회 943
10년 전 조회 904
10년 전 조회 926
10년 전 조회 1,026
10년 전 조회 973
10년 전 조회 868
10년 전 조회 923
10년 전 조회 1,310
10년 전 조회 1,741
10년 전 조회 1,313
10년 전 조회 1,126
10년 전 조회 1,205
10년 전 조회 959
10년 전 조회 936
10년 전 조회 978
10년 전 조회 936
10년 전 조회 963
10년 전 조회 952
10년 전 조회 1,217
10년 전 조회 1,069
10년 전 조회 1,747
10년 전 조회 1,329
10년 전 조회 1,027
10년 전 조회 1,136
10년 전 조회 1,347
10년 전 조회 1,098
10년 전 조회 1,260
10년 전 조회 1,094
10년 전 조회 1,202
10년 전 조회 1,027
10년 전 조회 1,008
10년 전 조회 1,008
10년 전 조회 1,065
10년 전 조회 1,038
10년 전 조회 1,098
10년 전 조회 1,089
10년 전 조회 1,068
10년 전 조회 1,206
10년 전 조회 1,191
10년 전 조회 991
10년 전 조회 1,297
10년 전 조회 1,637
10년 전 조회 1,092
10년 전 조회 1,339
10년 전 조회 1,305
10년 전 조회 1,161
10년 전 조회 1,116
10년 전 조회 1,070
10년 전 조회 1,187
10년 전 조회 949
10년 전 조회 1,009
10년 전 조회 1,225
10년 전 조회 1,054
10년 전 조회 1,008
10년 전 조회 999
10년 전 조회 987
10년 전 조회 1,004
10년 전 조회 986
10년 전 조회 1,013
10년 전 조회 1,012
10년 전 조회 1,122
10년 전 조회 974
10년 전 조회 972
10년 전 조회 1,052
10년 전 조회 1,776
10년 전 조회 987
10년 전 조회 1,012
10년 전 조회 1,117
10년 전 조회 1,041
10년 전 조회 1,151
10년 전 조회 1,123
10년 전 조회 1,004
10년 전 조회 1,003
10년 전 조회 1,075
10년 전 조회 1,030
10년 전 조회 973
10년 전 조회 923
10년 전 조회 897
10년 전 조회 935
10년 전 조회 1,331
10년 전 조회 928
10년 전 조회 1,067