PHP ANOTATION , Reflection 입니다.

· 10년 전 · 539

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년 전 조회 546
10년 전 조회 533
10년 전 조회 555
10년 전 조회 682
10년 전 조회 542
10년 전 조회 505
10년 전 조회 522
10년 전 조회 635
10년 전 조회 546
10년 전 조회 481
10년 전 조회 499
10년 전 조회 500
10년 전 조회 462
10년 전 조회 472
10년 전 조회 680
10년 전 조회 890
10년 전 조회 695
10년 전 조회 500
10년 전 조회 502
10년 전 조회 456
10년 전 조회 482
10년 전 조회 580
10년 전 조회 515
10년 전 조회 433
10년 전 조회 482
10년 전 조회 876
10년 전 조회 1,326
10년 전 조회 896
10년 전 조회 693
10년 전 조회 666
10년 전 조회 527
10년 전 조회 514
10년 전 조회 538
10년 전 조회 507
10년 전 조회 524
10년 전 조회 549
10년 전 조회 677
10년 전 조회 586
10년 전 조회 1,322
10년 전 조회 878
10년 전 조회 597
10년 전 조회 671
10년 전 조회 936
10년 전 조회 653
10년 전 조회 783
10년 전 조회 625
10년 전 조회 732
10년 전 조회 562
10년 전 조회 543
10년 전 조회 540
10년 전 조회 590
10년 전 조회 547
10년 전 조회 606
10년 전 조회 609
10년 전 조회 590
10년 전 조회 748
10년 전 조회 762
10년 전 조회 525
10년 전 조회 827
10년 전 조회 1,182
10년 전 조회 632
10년 전 조회 863
10년 전 조회 860
10년 전 조회 693
10년 전 조회 627
10년 전 조회 613
10년 전 조회 714
10년 전 조회 485
10년 전 조회 520
10년 전 조회 738
10년 전 조회 564
10년 전 조회 530
10년 전 조회 515
10년 전 조회 522
10년 전 조회 533
10년 전 조회 512
10년 전 조회 529
10년 전 조회 550
10년 전 조회 645
10년 전 조회 481
10년 전 조회 504
10년 전 조회 592
10년 전 조회 1,341
10년 전 조회 543
10년 전 조회 541
10년 전 조회 668
10년 전 조회 554
10년 전 조회 739
10년 전 조회 652
10년 전 조회 541
10년 전 조회 543
10년 전 조회 598
10년 전 조회 587
10년 전 조회 483
10년 전 조회 481
10년 전 조회 447
10년 전 조회 490
10년 전 조회 885
10년 전 조회 496
10년 전 조회 614
🐛 버그신고