v

PHP ANOTATION , Reflection

· 14년 전 · 1289
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'
 
 
 
 
 
 
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,989
14년 전 조회 2,248
14년 전 조회 1,769
14년 전 조회 2,797
14년 전 조회 1,446
14년 전 조회 1,453
14년 전 조회 1,303
14년 전 조회 2,111
14년 전 조회 1,717
14년 전 조회 1,432
14년 전 조회 6,015
14년 전 조회 2,569
14년 전 조회 1,848
14년 전 조회 1,312
14년 전 조회 1만
14년 전 조회 2,223
14년 전 조회 1,232
14년 전 조회 1,248
14년 전 조회 2,140
14년 전 조회 2,669
14년 전 조회 2,187
14년 전 조회 1,429
14년 전 조회 2,722
14년 전 조회 2,714
14년 전 조회 3,714
14년 전 조회 1,808
14년 전 조회 1,924
14년 전 조회 1,463
14년 전 조회 1,583
14년 전 조회 2,807
14년 전 조회 1,574
14년 전 조회 3,089
14년 전 조회 1,282
14년 전 조회 4,158
14년 전 조회 1,368
14년 전 조회 2,726
14년 전 조회 4,124
14년 전 조회 1,403
14년 전 조회 1,590
14년 전 조회 1,958
14년 전 조회 1,464
14년 전 조회 1,990
14년 전 조회 1,891
14년 전 조회 2,002
14년 전 조회 1,798
14년 전 조회 1,359
14년 전 조회 1,839
14년 전 조회 1,851
14년 전 조회 1,704
14년 전 조회 1,290
14년 전 조회 1,210
14년 전 조회 1,648
14년 전 조회 1,133
14년 전 조회 3,713
14년 전 조회 1,172
14년 전 조회 1,563
14년 전 조회 1,184
14년 전 조회 1,231
14년 전 조회 2,485
14년 전 조회 1,522
14년 전 조회 2,001
14년 전 조회 1,270
14년 전 조회 1,835
14년 전 조회 2,367
14년 전 조회 1,416
14년 전 조회 1,879
14년 전 조회 1,417
14년 전 조회 1,779
14년 전 조회 3,220
14년 전 조회 1,271
14년 전 조회 5,443
14년 전 조회 1,275
14년 전 조회 1,461
14년 전 조회 1,270
14년 전 조회 4,013
14년 전 조회 1,080
14년 전 조회 1,425
14년 전 조회 1,712
14년 전 조회 1,741
14년 전 조회 1,196
14년 전 조회 1,830
14년 전 조회 1,292
14년 전 조회 1,168
14년 전 조회 2,844
14년 전 조회 1,580
14년 전 조회 1,176
14년 전 조회 1,161
14년 전 조회 2,204
14년 전 조회 1,357
14년 전 조회 1,769
14년 전 조회 1,758
14년 전 조회 2,384
14년 전 조회 2,427
14년 전 조회 1,699
14년 전 조회 1,319
14년 전 조회 1,278
14년 전 조회 1,502
14년 전 조회 1,678
14년 전 조회 3,165
14년 전 조회 1,146