PHP ANOTATION , Reflection 입니다.

· 10년 전 · 454

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년 전 조회 467
10년 전 조회 456
10년 전 조회 475
10년 전 조회 597
10년 전 조회 477
10년 전 조회 424
10년 전 조회 450
10년 전 조회 557
10년 전 조회 459
10년 전 조회 415
10년 전 조회 426
10년 전 조회 421
10년 전 조회 387
10년 전 조회 390
10년 전 조회 603
10년 전 조회 807
10년 전 조회 622
10년 전 조회 422
10년 전 조회 418
10년 전 조회 390
10년 전 조회 398
10년 전 조회 514
10년 전 조회 431
10년 전 조회 352
10년 전 조회 400
10년 전 조회 788
10년 전 조회 1,250
10년 전 조회 817
10년 전 조회 611
10년 전 조회 587
10년 전 조회 449
10년 전 조회 441
10년 전 조회 455
10년 전 조회 421
10년 전 조회 442
10년 전 조회 468
10년 전 조회 603
10년 전 조회 504
10년 전 조회 1,233
10년 전 조회 787
10년 전 조회 510
10년 전 조회 591
10년 전 조회 839
10년 전 조회 561
10년 전 조회 701
10년 전 조회 544
10년 전 조회 647
10년 전 조회 478
10년 전 조회 457
10년 전 조회 455
10년 전 조회 506
10년 전 조회 469
10년 전 조회 520
10년 전 조회 524
10년 전 조회 505
10년 전 조회 664
10년 전 조회 676
10년 전 조회 438
10년 전 조회 741
10년 전 조회 1,088
10년 전 조회 542
10년 전 조회 772
10년 전 조회 771
10년 전 조회 605
10년 전 조회 543
10년 전 조회 519
10년 전 조회 615
10년 전 조회 387
10년 전 조회 422
10년 전 조회 636
10년 전 조회 479
10년 전 조회 439
10년 전 조회 428
10년 전 조회 439
10년 전 조회 439
10년 전 조회 417
10년 전 조회 427
10년 전 조회 452
10년 전 조회 559
10년 전 조회 400
10년 전 조회 414
10년 전 조회 493
10년 전 조회 1,237
10년 전 조회 460
10년 전 조회 435
10년 전 조회 564
10년 전 조회 448
10년 전 조회 629
10년 전 조회 561
10년 전 조회 437
10년 전 조회 445
10년 전 조회 490
10년 전 조회 486
10년 전 조회 379
10년 전 조회 386
10년 전 조회 337
10년 전 조회 384
10년 전 조회 791
10년 전 조회 394
10년 전 조회 500
🐛 버그신고