PHP ANOTATION , Reflection 입니다.

· 10년 전 · 524

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년 전 조회 668
10년 전 조회 535
10년 전 조회 491
10년 전 조회 510
10년 전 조회 621
10년 전 조회 533
10년 전 조회 475
10년 전 조회 486
10년 전 조회 490
10년 전 조회 449
10년 전 조회 456
10년 전 조회 669
10년 전 조회 883
10년 전 조회 686
10년 전 조회 490
10년 전 조회 491
10년 전 조회 449
10년 전 조회 471
10년 전 조회 573
10년 전 조회 508
10년 전 조회 423
10년 전 조회 471
10년 전 조회 862
10년 전 조회 1,318
10년 전 조회 887
10년 전 조회 683
10년 전 조회 655
10년 전 조회 521
10년 전 조회 501
10년 전 조회 532
10년 전 조회 497
10년 전 조회 510
10년 전 조회 540
10년 전 조회 668
10년 전 조회 571
10년 전 조회 1,308
10년 전 조회 866
10년 전 조회 581
10년 전 조회 659
10년 전 조회 925
10년 전 조회 644
10년 전 조회 771
10년 전 조회 610
10년 전 조회 715
10년 전 조회 544
10년 전 조회 534
10년 전 조회 525
10년 전 조회 577
10년 전 조회 535
10년 전 조회 594
10년 전 조회 590
10년 전 조회 584
10년 전 조회 738
10년 전 조회 742
10년 전 조회 511
10년 전 조회 814
10년 전 조회 1,174
10년 전 조회 619
10년 전 조회 851
10년 전 조회 850
10년 전 조회 682
10년 전 조회 619
10년 전 조회 600
10년 전 조회 698
10년 전 조회 472
10년 전 조회 506
10년 전 조회 721
10년 전 조회 555
10년 전 조회 521
10년 전 조회 498
10년 전 조회 514
10년 전 조회 524
10년 전 조회 496
10년 전 조회 513
10년 전 조회 538
10년 전 조회 635
10년 전 조회 470
10년 전 조회 493
10년 전 조회 581
10년 전 조회 1,331
10년 전 조회 531
10년 전 조회 525
10년 전 조회 660
10년 전 조회 544
10년 전 조회 726
10년 전 조회 643
10년 전 조회 532
10년 전 조회 532
10년 전 조회 583
10년 전 조회 577
10년 전 조회 473
10년 전 조회 471
10년 전 조회 431
10년 전 조회 481
10년 전 조회 878
10년 전 조회 483
10년 전 조회 601
🐛 버그신고