PHP ANOTATION , Reflection 입니다.

· 10년 전 · 419

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년 전 조회 437
10년 전 조회 422
10년 전 조회 448
10년 전 조회 570
10년 전 조회 441
10년 전 조회 395
10년 전 조회 419
10년 전 조회 521
10년 전 조회 430
10년 전 조회 383
10년 전 조회 396
10년 전 조회 389
10년 전 조회 355
10년 전 조회 358
10년 전 조회 568
10년 전 조회 781
10년 전 조회 588
10년 전 조회 392
10년 전 조회 383
10년 전 조회 358
10년 전 조회 364
10년 전 조회 480
10년 전 조회 396
10년 전 조회 319
10년 전 조회 364
10년 전 조회 755
10년 전 조회 1,215
10년 전 조회 787
10년 전 조회 575
10년 전 조회 552
10년 전 조회 423
10년 전 조회 409
10년 전 조회 420
10년 전 조회 385
10년 전 조회 414
10년 전 조회 434
10년 전 조회 566
10년 전 조회 471
10년 전 조회 1,198
10년 전 조회 757
10년 전 조회 479
10년 전 조회 557
10년 전 조회 814
10년 전 조회 530
10년 전 조회 663
10년 전 조회 507
10년 전 조회 612
10년 전 조회 445
10년 전 조회 418
10년 전 조회 420
10년 전 조회 475
10년 전 조회 437
10년 전 조회 490
10년 전 조회 485
10년 전 조회 473
10년 전 조회 632
10년 전 조회 640
10년 전 조회 408
10년 전 조회 703
10년 전 조회 1,055
10년 전 조회 513
10년 전 조회 738
10년 전 조회 742
10년 전 조회 570
10년 전 조회 513
10년 전 조회 481
10년 전 조회 580
10년 전 조회 357
10년 전 조회 392
10년 전 조회 609
10년 전 조회 442
10년 전 조회 407
10년 전 조회 390
10년 전 조회 406
10년 전 조회 404
10년 전 조회 382
10년 전 조회 393
10년 전 조회 423
10년 전 조회 520
10년 전 조회 360
10년 전 조회 392
10년 전 조회 464
10년 전 조회 1,202
10년 전 조회 414
10년 전 조회 404
10년 전 조회 529
10년 전 조회 410
10년 전 조회 589
10년 전 조회 522
10년 전 조회 406
10년 전 조회 403
10년 전 조회 455
10년 전 조회 451
10년 전 조회 343
10년 전 조회 349
10년 전 조회 302
10년 전 조회 353
10년 전 조회 754
10년 전 조회 366
10년 전 조회 470
🐛 버그신고