v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2913
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,187건
+
제목 글쓴이 날짜 조회
13-03-03 조회 6,288
13-03-01 조회 5,617
13-03-01 조회 8,359
13-03-01 조회 6,363
13-02-26 조회 3,973
13-02-26 조회 3,929
13-02-26 조회 4,800
13-02-24 조회 8,201
13-02-24 조회 4,305
13-02-24 조회 3,536
13-02-24 조회 5,352
13-02-24 조회 5,341
13-02-24 조회 4,403
13-02-24 조회 5,739
13-02-24 조회 9,436
13-02-14 조회 5,180
13-02-13 조회 9,113
13-01-29 조회 7,725
13-01-24 조회 5,074
13-01-24 조회 4,952
13-01-17 조회 4,374
13-01-16 조회 4,412
13-01-08 조회 4,431
12-12-27 조회 4,127
12-12-20 조회 1.1만
12-12-20 조회 3,427
12-12-06 조회 4,436
12-12-01 조회 4,193
12-11-28 조회 5,768
12-11-25 조회 5,478
12-10-20 조회 4,706
12-10-03 조회 4,875
12-09-26 조회 5,028
12-09-15 조회 8,470
12-09-14 조회 5,484
12-09-11 조회 4,006
12-09-10 조회 3,997
12-09-05 조회 8,887
12-08-29 조회 4,715
12-08-26 조회 3,834
12-08-23 조회 3,539
12-08-22 조회 3,617
12-08-22 조회 4,430
12-08-21 조회 3,573
12-08-20 조회 3,499
12-08-20 조회 9,305
12-08-15 조회 4,425
12-08-13 조회 3,339
12-08-11 조회 4,746
12-08-05 조회 4,615
12-08-03 조회 3,384
12-08-03 조회 4,080
12-08-02 조회 5,067
12-07-29 조회 4,184
12-07-26 조회 3,751
12-07-26 조회 3,615
12-07-22 조회 3,539
12-07-20 조회 3,366
12-07-19 조회 4,236
12-07-19 조회 3,502
12-07-16 조회 3,613
12-07-16 조회 4,531
12-07-15 조회 3,617
12-07-12 조회 7,428
12-07-12 조회 5,073
12-07-11 조회 3,123
12-07-09 조회 3,281
12-07-05 조회 3,890
12-07-04 조회 4,474
12-07-04 조회 3,874
12-07-04 조회 4,400
12-06-29 조회 3,870
12-06-27 조회 3,467
12-06-24 조회 3,934
12-06-22 조회 4,247
12-06-22 조회 8,651
12-06-22 조회 3,306
12-06-21 조회 3,323
12-06-17 조회 3,971
12-06-14 조회 4,056
12-06-14 조회 3,354
12-06-08 조회 4,487
12-06-06 조회 3,438
12-06-04 조회 4,224
12-05-26 조회 5,020
12-05-26 조회 3,975
12-05-25 조회 3,269
12-05-24 조회 3,364
12-05-22 조회 3,424
12-05-20 조회 3,064
12-05-16 조회 3,178
12-05-15 조회 3,563
12-05-10 조회 3,987
12-05-08 조회 3,532
12-05-04 조회 3,372
12-05-03 조회 4,329
12-05-02 조회 3,467
12-05-02 조회 3,224
12-05-02 조회 3,333
12-04-26 조회 3,493