v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2786
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-11-16 조회 3,414
11-11-15 조회 2,538
11-11-15 조회 3,166
11-11-15 조회 2,605
11-11-14 조회 2,687
11-11-14 조회 3,639
11-11-14 조회 3,433
11-11-14 조회 4,106
11-11-14 조회 2,728
11-11-14 조회 2,655
11-11-13 조회 3,958
11-11-12 조회 2,604
11-11-12 조회 2,721
11-11-12 조회 3,927
11-11-11 조회 2,845
11-11-11 조회 2,797
11-11-11 조회 2,484
11-11-11 조회 2,799
11-11-11 조회 3,934
11-11-11 조회 2,400
11-11-11 조회 4,635
11-11-11 조회 2,669
11-11-11 조회 2,494
11-11-11 조회 2,355
11-11-11 조회 2,762
11-11-11 조회 2,554
11-11-11 조회 2,546
11-11-10 조회 2,965
11-11-10 조회 2,404
11-11-10 조회 3,079
11-11-10 조회 3,628
11-11-10 조회 2,334
11-11-10 조회 2,467
11-11-10 조회 2,308
11-11-09 조회 2,494
11-11-09 조회 3,179
11-11-09 조회 2,675
11-11-09 조회 2,819
11-11-08 조회 2,582
11-11-08 조회 2,906
11-11-08 조회 2,249
11-11-08 조회 3,185
11-11-08 조회 2,471
11-11-08 조회 3,248
11-11-06 조회 1만
11-11-06 조회 2,559
11-11-06 조회 3,554
11-11-06 조회 3,351
11-11-06 조회 3,643
11-11-06 조회 3,821
11-11-05 조회 2,361
11-11-05 조회 2,526
11-11-04 조회 8,377
11-11-04 조회 2,490
11-11-04 조회 2,546
11-11-04 조회 3,550
11-11-04 조회 2,450
11-11-04 조회 2,626
11-11-03 조회 3,888
11-11-03 조회 2,554
11-11-03 조회 5,516
11-11-02 조회 5,781
11-11-01 조회 3,008
11-11-01 조회 2,492
11-11-01 조회 3,129
11-11-01 조회 2,440
11-11-01 조회 2,773
11-11-01 조회 2,293
11-11-01 조회 9,302
11-11-01 조회 2,857
11-10-31 조회 2,247
11-10-27 조회 2,490
11-10-26 조회 3,106
11-10-26 조회 2,589
11-10-26 조회 2,439
11-10-26 조회 2,483
11-10-26 조회 2,376
11-10-25 조회 2,369
11-10-25 조회 2,488
11-10-25 조회 2,444
11-10-25 조회 2,419
11-10-24 조회 2,464
11-10-24 조회 2,725
11-10-24 조회 2,733
11-10-23 조회 3,078
11-10-23 조회 2,677
11-10-23 조회 2,585
11-10-21 조회 2,451
11-10-21 조회 2,382
11-10-21 조회 2,353
11-10-21 조회 2,658
11-10-20 조회 3,909
11-10-19 조회 2,405
11-10-19 조회 2,786
11-10-19 조회 3,901
11-10-19 조회 3,055
11-10-19 조회 2,770
11-10-19 조회 6,593
11-10-18 조회 3,895
11-10-18 조회 2,510