v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2944
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건
+
제목 글쓴이 날짜 조회
11-11-16 조회 3,536
11-11-15 조회 2,656
11-11-15 조회 3,292
11-11-15 조회 2,741
11-11-14 조회 2,842
11-11-14 조회 3,785
11-11-14 조회 3,582
11-11-14 조회 4,275
11-11-14 조회 2,872
11-11-14 조회 2,767
11-11-13 조회 4,061
11-11-12 조회 2,701
11-11-12 조회 2,828
11-11-12 조회 4,053
11-11-11 조회 2,956
11-11-11 조회 2,904
11-11-11 조회 2,573
11-11-11 조회 2,896
11-11-11 조회 4,035
11-11-11 조회 2,501
11-11-11 조회 4,747
11-11-11 조회 2,773
11-11-11 조회 2,585
11-11-11 조회 2,454
11-11-11 조회 2,874
11-11-11 조회 2,648
11-11-11 조회 2,641
11-11-10 조회 3,095
11-11-10 조회 2,559
11-11-10 조회 3,191
11-11-10 조회 3,756
11-11-10 조회 2,446
11-11-10 조회 2,576
11-11-10 조회 2,410
11-11-09 조회 2,621
11-11-09 조회 3,338
11-11-09 조회 2,812
11-11-09 조회 2,952
11-11-08 조회 2,710
11-11-08 조회 3,044
11-11-08 조회 2,372
11-11-08 조회 3,328
11-11-08 조회 2,619
11-11-08 조회 3,388
11-11-06 조회 1만
11-11-06 조회 2,687
11-11-06 조회 3,688
11-11-06 조회 3,493
11-11-06 조회 3,795
11-11-06 조회 3,977
11-11-05 조회 2,514
11-11-05 조회 2,688
11-11-04 조회 8,587
11-11-04 조회 2,637
11-11-04 조회 2,689
11-11-04 조회 3,699
11-11-04 조회 2,588
11-11-04 조회 2,765
11-11-03 조회 4,035
11-11-03 조회 2,708
11-11-03 조회 5,670
11-11-02 조회 5,943
11-11-01 조회 3,233
11-11-01 조회 2,677
11-11-01 조회 3,289
11-11-01 조회 2,585
11-11-01 조회 2,922
11-11-01 조회 2,433
11-11-01 조회 9,449
11-11-01 조회 3,000
11-10-31 조회 2,380
11-10-27 조회 2,647
11-10-26 조회 3,226
11-10-26 조회 2,730
11-10-26 조회 2,583
11-10-26 조회 2,609
11-10-26 조회 2,489
11-10-25 조회 2,554
11-10-25 조회 2,661
11-10-25 조회 2,601
11-10-25 조회 2,574
11-10-24 조회 2,609
11-10-24 조회 2,895
11-10-24 조회 2,908
11-10-23 조회 3,276
11-10-23 조회 2,866
11-10-23 조회 2,755
11-10-21 조회 2,601
11-10-21 조회 2,532
11-10-21 조회 2,519
11-10-21 조회 2,919
11-10-20 조회 4,076
11-10-19 조회 2,576
11-10-19 조회 2,986
11-10-19 조회 4,108
11-10-19 조회 3,260
11-10-19 조회 2,961
11-10-19 조회 6,783
11-10-18 조회 4,115
11-10-18 조회 2,668