PHP ANOTATION , Reflection 입니다.

· 10년 전 · 549

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년 전 조회 551
10년 전 조회 537
10년 전 조회 556
10년 전 조회 687
10년 전 조회 554
10년 전 조회 514
10년 전 조회 525
10년 전 조회 641
10년 전 조회 553
10년 전 조회 489
10년 전 조회 505
10년 전 조회 507
10년 전 조회 470
10년 전 조회 478
10년 전 조회 684
10년 전 조회 895
10년 전 조회 703
10년 전 조회 504
10년 전 조회 508
10년 전 조회 462
10년 전 조회 489
10년 전 조회 588
10년 전 조회 522
10년 전 조회 436
10년 전 조회 486
10년 전 조회 881
10년 전 조회 1,331
10년 전 조회 903
10년 전 조회 699
10년 전 조회 670
10년 전 조회 533
10년 전 조회 522
10년 전 조회 541
10년 전 조회 516
10년 전 조회 530
10년 전 조회 554
10년 전 조회 689
10년 전 조회 593
10년 전 조회 1,330
10년 전 조회 880
10년 전 조회 603
10년 전 조회 678
10년 전 조회 938
10년 전 조회 658
10년 전 조회 790
10년 전 조회 633
10년 전 조회 740
10년 전 조회 571
10년 전 조회 549
10년 전 조회 550
10년 전 조회 595
10년 전 조회 552
10년 전 조회 615
10년 전 조회 616
10년 전 조회 596
10년 전 조회 757
10년 전 조회 765
10년 전 조회 531
10년 전 조회 835
10년 전 조회 1,188
10년 전 조회 637
10년 전 조회 870
10년 전 조회 866
10년 전 조회 700
10년 전 조회 637
10년 전 조회 617
10년 전 조회 718
10년 전 조회 491
10년 전 조회 524
10년 전 조회 741
10년 전 조회 573
10년 전 조회 534
10년 전 조회 518
10년 전 조회 527
10년 전 조회 540
10년 전 조회 520
10년 전 조회 542
10년 전 조회 559
10년 전 조회 651
10년 전 조회 486
10년 전 조회 510
10년 전 조회 597
10년 전 조회 1,344
10년 전 조회 547
10년 전 조회 546
10년 전 조회 675
10년 전 조회 559
10년 전 조회 742
10년 전 조회 658
10년 전 조회 546
10년 전 조회 546
10년 전 조회 603
10년 전 조회 593
10년 전 조회 491
10년 전 조회 485
10년 전 조회 453
10년 전 조회 495
10년 전 조회 896
10년 전 조회 502
10년 전 조회 621
🐛 버그신고