PHP ANOTATION , Reflection 입니다.

· 10년 전 · 464

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년 전 조회 473
10년 전 조회 463
10년 전 조회 483
10년 전 조회 607
10년 전 조회 480
10년 전 조회 436
10년 전 조회 457
10년 전 조회 561
10년 전 조회 472
10년 전 조회 423
10년 전 조회 438
10년 전 조회 435
10년 전 조회 394
10년 전 조회 402
10년 전 조회 607
10년 전 조회 817
10년 전 조회 630
10년 전 조회 432
10년 전 조회 427
10년 전 조회 398
10년 전 조회 407
10년 전 조회 517
10년 전 조회 437
10년 전 조회 358
10년 전 조회 405
10년 전 조회 798
10년 전 조회 1,259
10년 전 조회 824
10년 전 조회 623
10년 전 조회 596
10년 전 조회 456
10년 전 조회 452
10년 전 조회 465
10년 전 조회 430
10년 전 조회 448
10년 전 조회 475
10년 전 조회 609
10년 전 조회 513
10년 전 조회 1,240
10년 전 조회 797
10년 전 조회 519
10년 전 조회 597
10년 전 조회 848
10년 전 조회 571
10년 전 조회 709
10년 전 조회 548
10년 전 조회 655
10년 전 조회 485
10년 전 조회 469
10년 전 조회 465
10년 전 조회 513
10년 전 조회 479
10년 전 조회 530
10년 전 조회 529
10년 전 조회 515
10년 전 조회 673
10년 전 조회 688
10년 전 조회 448
10년 전 조회 753
10년 전 조회 1,098
10년 전 조회 551
10년 전 조회 782
10년 전 조회 781
10년 전 조회 616
10년 전 조회 550
10년 전 조회 530
10년 전 조회 628
10년 전 조회 401
10년 전 조회 432
10년 전 조회 646
10년 전 조회 487
10년 전 조회 445
10년 전 조회 437
10년 전 조회 451
10년 전 조회 448
10년 전 조회 429
10년 전 조회 435
10년 전 조회 463
10년 전 조회 570
10년 전 조회 408
10년 전 조회 425
10년 전 조회 503
10년 전 조회 1,243
10년 전 조회 470
10년 전 조회 447
10년 전 조회 572
10년 전 조회 457
10년 전 조회 637
10년 전 조회 572
10년 전 조회 449
10년 전 조회 453
10년 전 조회 499
10년 전 조회 498
10년 전 조회 390
10년 전 조회 397
10년 전 조회 351
10년 전 조회 397
10년 전 조회 798
10년 전 조회 405
10년 전 조회 514
🐛 버그신고