PHP ANOTATION , Reflection 입니다.

· 10년 전 · 568

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년 전 조회 558
10년 전 조회 557
10년 전 조회 564
10년 전 조회 707
10년 전 조회 572
10년 전 조회 531
10년 전 조회 540
10년 전 조회 660
10년 전 조회 565
10년 전 조회 506
10년 전 조회 526
10년 전 조회 522
10년 전 조회 486
10년 전 조회 497
10년 전 조회 696
10년 전 조회 903
10년 전 조회 725
10년 전 조회 523
10년 전 조회 528
10년 전 조회 482
10년 전 조회 510
10년 전 조회 607
10년 전 조회 532
10년 전 조회 459
10년 전 조회 501
10년 전 조회 897
10년 전 조회 1,345
10년 전 조회 909
10년 전 조회 720
10년 전 조회 691
10년 전 조회 551
10년 전 조회 539
10년 전 조회 561
10년 전 조회 532
10년 전 조회 542
10년 전 조회 573
10년 전 조회 699
10년 전 조회 616
10년 전 조회 1,344
10년 전 조회 899
10년 전 조회 615
10년 전 조회 698
10년 전 조회 945
10년 전 조회 673
10년 전 조회 812
10년 전 조회 648
10년 전 조회 757
10년 전 조회 593
10년 전 조회 571
10년 전 조회 569
10년 전 조회 616
10년 전 조회 572
10년 전 조회 636
10년 전 조회 639
10년 전 조회 616
10년 전 조회 774
10년 전 조회 786
10년 전 조회 551
10년 전 조회 852
10년 전 조회 1,202
10년 전 조회 658
10년 전 조회 891
10년 전 조회 883
10년 전 조회 721
10년 전 조회 658
10년 전 조회 635
10년 전 조회 738
10년 전 조회 509
10년 전 조회 536
10년 전 조회 760
10년 전 조회 596
10년 전 조회 552
10년 전 조회 529
10년 전 조회 548
10년 전 조회 566
10년 전 조회 539
10년 전 조회 555
10년 전 조회 573
10년 전 조회 676
10년 전 조회 506
10년 전 조회 536
10년 전 조회 617
10년 전 조회 1,355
10년 전 조회 570
10년 전 조회 565
10년 전 조회 686
10년 전 조회 577
10년 전 조회 756
10년 전 조회 669
10년 전 조회 558
10년 전 조회 566
10년 전 조회 619
10년 전 조회 608
10년 전 조회 505
10년 전 조회 499
10년 전 조회 465
10년 전 조회 507
10년 전 조회 906
10년 전 조회 509
10년 전 조회 632
🐛 버그신고