PHP ANOTATION , Reflection 입니다.

· 10년 전 · 421

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년 전 조회 437
10년 전 조회 424
10년 전 조회 449
10년 전 조회 573
10년 전 조회 444
10년 전 조회 396
10년 전 조회 421
10년 전 조회 522
10년 전 조회 432
10년 전 조회 385
10년 전 조회 397
10년 전 조회 390
10년 전 조회 357
10년 전 조회 359
10년 전 조회 572
10년 전 조회 781
10년 전 조회 590
10년 전 조회 393
10년 전 조회 385
10년 전 조회 360
10년 전 조회 366
10년 전 조회 480
10년 전 조회 397
10년 전 조회 320
10년 전 조회 365
10년 전 조회 756
10년 전 조회 1,215
10년 전 조회 788
10년 전 조회 576
10년 전 조회 553
10년 전 조회 423
10년 전 조회 409
10년 전 조회 421
10년 전 조회 386
10년 전 조회 417
10년 전 조회 435
10년 전 조회 567
10년 전 조회 471
10년 전 조회 1,199
10년 전 조회 758
10년 전 조회 479
10년 전 조회 557
10년 전 조회 815
10년 전 조회 530
10년 전 조회 663
10년 전 조회 507
10년 전 조회 612
10년 전 조회 445
10년 전 조회 420
10년 전 조회 422
10년 전 조회 476
10년 전 조회 438
10년 전 조회 492
10년 전 조회 486
10년 전 조회 474
10년 전 조회 633
10년 전 조회 642
10년 전 조회 409
10년 전 조회 705
10년 전 조회 1,056
10년 전 조회 513
10년 전 조회 738
10년 전 조회 743
10년 전 조회 570
10년 전 조회 514
10년 전 조회 481
10년 전 조회 581
10년 전 조회 357
10년 전 조회 392
10년 전 조회 609
10년 전 조회 442
10년 전 조회 408
10년 전 조회 391
10년 전 조회 406
10년 전 조회 405
10년 전 조회 383
10년 전 조회 397
10년 전 조회 425
10년 전 조회 520
10년 전 조회 360
10년 전 조회 392
10년 전 조회 465
10년 전 조회 1,204
10년 전 조회 414
10년 전 조회 404
10년 전 조회 530
10년 전 조회 411
10년 전 조회 589
10년 전 조회 524
10년 전 조회 406
10년 전 조회 404
10년 전 조회 456
10년 전 조회 451
10년 전 조회 344
10년 전 조회 349
10년 전 조회 303
10년 전 조회 353
10년 전 조회 756
10년 전 조회 368
10년 전 조회 471
🐛 버그신고