PHP ANOTATION , Reflection 입니다.

· 10년 전 · 520

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년 전 조회 535
10년 전 조회 521
10년 전 조회 539
10년 전 조회 664
10년 전 조회 528
10년 전 조회 487
10년 전 조회 508
10년 전 조회 615
10년 전 조회 532
10년 전 조회 473
10년 전 조회 481
10년 전 조회 487
10년 전 조회 446
10년 전 조회 453
10년 전 조회 666
10년 전 조회 881
10년 전 조회 684
10년 전 조회 481
10년 전 조회 488
10년 전 조회 446
10년 전 조회 466
10년 전 조회 567
10년 전 조회 503
10년 전 조회 419
10년 전 조회 468
10년 전 조회 859
10년 전 조회 1,313
10년 전 조회 882
10년 전 조회 681
10년 전 조회 654
10년 전 조회 517
10년 전 조회 496
10년 전 조회 527
10년 전 조회 492
10년 전 조회 506
10년 전 조회 536
10년 전 조회 664
10년 전 조회 568
10년 전 조회 1,305
10년 전 조회 862
10년 전 조회 578
10년 전 조회 656
10년 전 조회 921
10년 전 조회 640
10년 전 조회 770
10년 전 조회 604
10년 전 조회 711
10년 전 조회 540
10년 전 조회 528
10년 전 조회 521
10년 전 조회 573
10년 전 조회 531
10년 전 조회 592
10년 전 조회 585
10년 전 조회 577
10년 전 조회 737
10년 전 조회 739
10년 전 조회 504
10년 전 조회 810
10년 전 조회 1,171
10년 전 조회 612
10년 전 조회 849
10년 전 조회 848
10년 전 조회 680
10년 전 조회 616
10년 전 조회 597
10년 전 조회 694
10년 전 조회 470
10년 전 조회 502
10년 전 조회 719
10년 전 조회 552
10년 전 조회 518
10년 전 조회 496
10년 전 조회 512
10년 전 조회 517
10년 전 조회 491
10년 전 조회 508
10년 전 조회 536
10년 전 조회 629
10년 전 조회 468
10년 전 조회 492
10년 전 조회 575
10년 전 조회 1,328
10년 전 조회 530
10년 전 조회 520
10년 전 조회 655
10년 전 조회 538
10년 전 조회 720
10년 전 조회 637
10년 전 조회 530
10년 전 조회 530
10년 전 조회 579
10년 전 조회 573
10년 전 조회 469
10년 전 조회 467
10년 전 조회 424
10년 전 조회 478
10년 전 조회 876
10년 전 조회 477
10년 전 조회 597
🐛 버그신고