v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2860
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건
+
제목 글쓴이 날짜 조회
12-01-11 조회 2,737
12-01-11 조회 1.2만
12-01-10 조회 2,840
12-01-08 조회 3,432
12-01-05 조회 5,318
11-12-29 조회 3,037
11-12-27 조회 2,829
11-12-25 조회 3,009
11-12-22 조회 3,440
11-12-14 조회 2,912
11-12-12 조회 3,524
11-11-28 조회 3,369
10-10-19 조회 2,827
08-09-05 조회 3,747
08-09-05 조회 3,567
08-06-14 조회 3,310
08-04-22 조회 3,577
08-04-17 조회 3,589
07-10-03 조회 4,199
07-10-03 조회 3,602
07-10-03 조회 7,283
07-10-03 조회 4,557
07-10-03 조회 3,255
07-10-03 조회 2,851
07-10-02 조회 3,565
07-10-02 조회 3,093
07-09-27 조회 5,004
07-09-27 조회 3,833
06-09-26 조회 3,512
06-09-26 조회 4,728
06-09-22 조회 3,899
06-09-22 조회 3,513
06-09-22 조회 4,261
06-09-21 조회 4,194
06-08-18 조회 3,686
05-11-30 조회 4,736
05-07-15 조회 4,584
05-03-23 조회 4,645
05-03-14 조회 3,313
05-03-13 조회 2,690
04-08-05 조회 5,761