PHP ANOTATION , Reflection 입니다.

· 10년 전 · 525

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년 전 조회 540
10년 전 조회 523
10년 전 조회 546
10년 전 조회 669
10년 전 조회 535
10년 전 조회 492
10년 전 조회 512
10년 전 조회 621
10년 전 조회 534
10년 전 조회 475
10년 전 조회 488
10년 전 조회 491
10년 전 조회 449
10년 전 조회 458
10년 전 조회 670
10년 전 조회 884
10년 전 조회 689
10년 전 조회 492
10년 전 조회 491
10년 전 조회 451
10년 전 조회 471
10년 전 조회 573
10년 전 조회 508
10년 전 조회 423
10년 전 조회 472
10년 전 조회 863
10년 전 조회 1,318
10년 전 조회 888
10년 전 조회 684
10년 전 조회 655
10년 전 조회 521
10년 전 조회 502
10년 전 조회 532
10년 전 조회 497
10년 전 조회 513
10년 전 조회 542
10년 전 조회 668
10년 전 조회 574
10년 전 조회 1,309
10년 전 조회 869
10년 전 조회 583
10년 전 조회 660
10년 전 조회 925
10년 전 조회 646
10년 전 조회 772
10년 전 조회 612
10년 전 조회 717
10년 전 조회 546
10년 전 조회 536
10년 전 조회 526
10년 전 조회 578
10년 전 조회 537
10년 전 조회 595
10년 전 조회 594
10년 전 조회 584
10년 전 조회 740
10년 전 조회 744
10년 전 조회 512
10년 전 조회 815
10년 전 조회 1,174
10년 전 조회 620
10년 전 조회 853
10년 전 조회 852
10년 전 조회 684
10년 전 조회 620
10년 전 조회 601
10년 전 조회 698
10년 전 조회 473
10년 전 조회 509
10년 전 조회 722
10년 전 조회 559
10년 전 조회 521
10년 전 조회 501
10년 전 조회 515
10년 전 조회 524
10년 전 조회 498
10년 전 조회 517
10년 전 조회 539
10년 전 조회 636
10년 전 조회 473
10년 전 조회 493
10년 전 조회 582
10년 전 조회 1,332
10년 전 조회 534
10년 전 조회 526
10년 전 조회 661
10년 전 조회 547
10년 전 조회 727
10년 전 조회 644
10년 전 조회 534
10년 전 조회 533
10년 전 조회 587
10년 전 조회 578
10년 전 조회 474
10년 전 조회 472
10년 전 조회 432
10년 전 조회 483
10년 전 조회 879
10년 전 조회 485
10년 전 조회 602
🐛 버그신고