PHP ANOTATION , Reflection 입니다.

· 10년 전 · 541

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년 전 조회 548
10년 전 조회 533
10년 전 조회 555
10년 전 조회 684
10년 전 조회 546
10년 전 조회 507
10년 전 조회 524
10년 전 조회 638
10년 전 조회 547
10년 전 조회 485
10년 전 조회 501
10년 전 조회 504
10년 전 조회 464
10년 전 조회 473
10년 전 조회 680
10년 전 조회 891
10년 전 조회 695
10년 전 조회 501
10년 전 조회 504
10년 전 조회 458
10년 전 조회 484
10년 전 조회 583
10년 전 조회 518
10년 전 조회 434
10년 전 조회 483
10년 전 조회 877
10년 전 조회 1,328
10년 전 조회 898
10년 전 조회 695
10년 전 조회 669
10년 전 조회 530
10년 전 조회 519
10년 전 조회 539
10년 전 조회 511
10년 전 조회 527
10년 전 조회 551
10년 전 조회 682
10년 전 조회 589
10년 전 조회 1,326
10년 전 조회 879
10년 전 조회 599
10년 전 조회 673
10년 전 조회 937
10년 전 조회 653
10년 전 조회 785
10년 전 조회 629
10년 전 조회 735
10년 전 조회 566
10년 전 조회 543
10년 전 조회 542
10년 전 조회 592
10년 전 조회 548
10년 전 조회 608
10년 전 조회 611
10년 전 조회 591
10년 전 조회 751
10년 전 조회 763
10년 전 조회 528
10년 전 조회 830
10년 전 조회 1,185
10년 전 조회 633
10년 전 조회 868
10년 전 조회 862
10년 전 조회 696
10년 전 조회 631
10년 전 조회 614
10년 전 조회 715
10년 전 조회 488
10년 전 조회 523
10년 전 조회 740
10년 전 조회 570
10년 전 조회 532
10년 전 조회 515
10년 전 조회 526
10년 전 조회 535
10년 전 조회 515
10년 전 조회 533
10년 전 조회 553
10년 전 조회 647
10년 전 조회 482
10년 전 조회 507
10년 전 조회 594
10년 전 조회 1,343
10년 전 조회 546
10년 전 조회 543
10년 전 조회 671
10년 전 조회 556
10년 전 조회 740
10년 전 조회 655
10년 전 조회 542
10년 전 조회 544
10년 전 조회 599
10년 전 조회 589
10년 전 조회 486
10년 전 조회 482
10년 전 조회 451
10년 전 조회 493
10년 전 조회 889
10년 전 조회 499
10년 전 조회 617
🐛 버그신고