PHP ANOTATION , Reflection 입니다.

· 10년 전 · 1261

PHP 에서도 anotation 드리븐을 구현 할 수 있을거 같내요 ㅎ;
 
http://code.google.com/p/addendum/
 
 
 
잘만 활용 하면, 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'

|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
10년 전 조회 1,271
10년 전 조회 1,222
10년 전 조회 1,258
10년 전 조회 1,363
10년 전 조회 1,235
10년 전 조회 1,202
10년 전 조회 1,212
10년 전 조회 1,313
10년 전 조회 1,204
10년 전 조회 1,163
10년 전 조회 1,190
10년 전 조회 1,193
10년 전 조회 1,245
10년 전 조회 1,168
10년 전 조회 1,395
10년 전 조회 1,550
10년 전 조회 1,449
10년 전 조회 1,212
10년 전 조회 1,212
10년 전 조회 1,166
10년 전 조회 1,171
10년 전 조회 1,284
10년 전 조회 1,213
10년 전 조회 1,153
10년 전 조회 1,210
10년 전 조회 1,560
10년 전 조회 2,009
10년 전 조회 1,597
10년 전 조회 1,415
10년 전 조회 1,380
10년 전 조회 1,217
10년 전 조회 1,210
10년 전 조회 1,232
10년 전 조회 1,195
10년 전 조회 1,210
10년 전 조회 1,233
10년 전 조회 1,392
10년 전 조회 1,309
10년 전 조회 2,033
10년 전 조회 1,568
10년 전 조회 1,303
10년 전 조회 1,392
10년 전 조회 1,647
10년 전 조회 1,334
10년 전 조회 1,511
10년 전 조회 1,349
10년 전 조회 1,452
10년 전 조회 1,302
10년 전 조회 1,271
10년 전 조회 1,262
10년 전 조회 1,295
10년 전 조회 1,292
10년 전 조회 1,320
10년 전 조회 1,352
10년 전 조회 1,323
10년 전 조회 1,479
10년 전 조회 1,473
10년 전 조회 1,254
10년 전 조회 1,561
10년 전 조회 1,918
10년 전 조회 1,351
10년 전 조회 1,610
10년 전 조회 1,570
10년 전 조회 1,420
10년 전 조회 1,390
10년 전 조회 1,342
10년 전 조회 1,457
10년 전 조회 1,191
10년 전 조회 1,276
10년 전 조회 1,490
10년 전 조회 1,315
10년 전 조회 1,314
10년 전 조회 1,270
10년 전 조회 1,298
10년 전 조회 1,280
10년 전 조회 1,278
10년 전 조회 1,304
10년 전 조회 1,260
10년 전 조회 1,431
10년 전 조회 1,255
10년 전 조회 1,265
10년 전 조회 1,337
10년 전 조회 2,083
10년 전 조회 1,307
10년 전 조회 1,305
10년 전 조회 1,394
10년 전 조회 1,306
10년 전 조회 1,460
10년 전 조회 1,384
10년 전 조회 1,301
10년 전 조회 1,306
10년 전 조회 1,361
10년 전 조회 1,331
10년 전 조회 1,253
10년 전 조회 1,210
10년 전 조회 1,180
10년 전 조회 1,215
10년 전 조회 1,600
10년 전 조회 1,257
10년 전 조회 1,360