v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2867
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'
 
 
 
 
 
 
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
11-12-23 조회 3,999
11-12-23 조회 2,943
11-12-23 조회 4,768
11-12-23 조회 4,350
11-12-23 조회 2,719
11-12-23 조회 8,056
11-12-22 조회 3,055
11-12-22 조회 3,795
11-12-22 조회 3,541
11-12-22 조회 3,447
11-12-22 조회 3,644
11-12-21 조회 3,488
11-12-21 조회 3,275
11-12-21 조회 3,560
11-12-21 조회 3,941
11-12-21 조회 2,974
11-12-21 조회 3,483
11-12-21 조회 4,415
11-12-21 조회 4,243
11-12-21 조회 3,267
11-12-20 조회 3,733
11-12-19 조회 6,235
11-12-19 조회 2,911
11-12-19 조회 4,991
11-12-17 조회 3,841
11-12-17 조회 4,211
11-12-17 조회 3,503
11-12-16 조회 3,115
11-12-16 조회 3,271
11-12-15 조회 3,318
11-12-15 조회 3,418
11-12-15 조회 4,221
11-12-15 조회 5,514
11-12-15 조회 4,507
11-12-15 조회 3,196
11-12-15 조회 3,977
11-12-15 조회 4,148
11-12-14 조회 2,913
11-12-14 조회 4,330
11-12-14 조회 5,562
11-12-13 조회 4,106
11-12-13 조회 5,012
11-12-13 조회 6,039
11-12-13 조회 6,347
11-12-13 조회 4,752
11-12-12 조회 3,252
11-12-12 조회 3,533
11-12-12 조회 6,197
11-12-12 조회 4,577
11-12-12 조회 3,721
11-12-12 조회 6,091
11-12-11 조회 4,632
11-12-10 조회 2,753
11-12-10 조회 4,706
11-12-09 조회 2,819
11-12-09 조회 3,225
11-12-09 조회 4,142
11-12-09 조회 3,763
11-12-09 조회 3,956
11-12-09 조회 3,522
11-12-09 조회 4,472
11-12-09 조회 3,156
11-12-09 조회 3,307
11-12-09 조회 2,970
11-12-09 조회 3,776
11-12-08 조회 3,528
11-12-08 조회 3,475
11-12-08 조회 7,779
11-12-08 조회 4,109
11-12-08 조회 3,608
11-12-08 조회 2,876
11-12-08 조회 1.2만
11-12-08 조회 3,961
11-12-07 조회 2,836
11-12-07 조회 2,872
11-12-07 조회 3,867
11-12-07 조회 4,496
11-12-07 조회 3,959
11-12-07 조회 3,060
11-12-07 조회 4,389
11-12-06 조회 4,292
11-12-06 조회 5,629
11-12-06 조회 3,683
11-12-06 조회 3,603
11-12-05 조회 3,033
11-12-05 조회 3,319
11-12-05 조회 4,551
11-12-05 조회 3,302
11-12-05 조회 4,920
11-12-05 조회 2,882
11-12-05 조회 5,950
11-12-05 조회 3,081
11-12-05 조회 4,414
11-12-04 조회 5,716
11-12-04 조회 2,958
11-12-04 조회 3,309
11-12-03 조회 3,621
11-12-03 조회 2,988
11-12-03 조회 3,585
11-12-03 조회 3,499