PHP ANOTATION , Reflection 입니다.

· 10년 전 · 509

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년 전 조회 529
10년 전 조회 514
10년 전 조회 528
10년 전 조회 652
10년 전 조회 524
10년 전 조회 475
10년 전 조회 496
10년 전 조회 607
10년 전 조회 522
10년 전 조회 464
10년 전 조회 475
10년 전 조회 480
10년 전 조회 440
10년 전 조회 444
10년 전 조회 656
10년 전 조회 868
10년 전 조회 676
10년 전 조회 471
10년 전 조회 478
10년 전 조회 442
10년 전 조회 458
10년 전 조회 560
10년 전 조회 496
10년 전 조회 409
10년 전 조회 460
10년 전 조회 847
10년 전 조회 1,304
10년 전 조회 870
10년 전 조회 673
10년 전 조회 644
10년 전 조회 507
10년 전 조회 489
10년 전 조회 514
10년 전 조회 484
10년 전 조회 496
10년 전 조회 528
10년 전 조회 658
10년 전 조회 558
10년 전 조회 1,300
10년 전 조회 857
10년 전 조회 569
10년 전 조회 647
10년 전 조회 913
10년 전 조회 632
10년 전 조회 761
10년 전 조회 599
10년 전 조회 706
10년 전 조회 536
10년 전 조회 517
10년 전 조회 510
10년 전 조회 566
10년 전 조회 525
10년 전 조회 582
10년 전 조회 579
10년 전 조회 569
10년 전 조회 727
10년 전 조회 734
10년 전 조회 497
10년 전 조회 802
10년 전 조회 1,160
10년 전 조회 606
10년 전 조회 843
10년 전 조회 838
10년 전 조회 673
10년 전 조회 602
10년 전 조회 593
10년 전 조회 688
10년 전 조회 461
10년 전 조회 496
10년 전 조회 712
10년 전 조회 541
10년 전 조회 502
10년 전 조회 491
10년 전 조회 505
10년 전 조회 507
10년 전 조회 484
10년 전 조회 500
10년 전 조회 525
10년 전 조회 618
10년 전 조회 458
10년 전 조회 482
10년 전 조회 565
10년 전 조회 1,313
10년 전 조회 519
10년 전 조회 511
10년 전 조회 643
10년 전 조회 527
10년 전 조회 707
10년 전 조회 630
10년 전 조회 513
10년 전 조회 516
10년 전 조회 570
10년 전 조회 564
10년 전 조회 457
10년 전 조회 454
10년 전 조회 412
10년 전 조회 465
10년 전 조회 865
10년 전 조회 465
10년 전 조회 584
🐛 버그신고