PHP ANOTATION , Reflection 입니다.

· 10년 전 · 384

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년 전 조회 403
10년 전 조회 391
10년 전 조회 409
10년 전 조회 524
10년 전 조회 397
10년 전 조회 351
10년 전 조회 378
10년 전 조회 483
10년 전 조회 387
10년 전 조회 341
10년 전 조회 352
10년 전 조회 349
10년 전 조회 312
10년 전 조회 316
10년 전 조회 524
10년 전 조회 742
10년 전 조회 551
10년 전 조회 356
10년 전 조회 347
10년 전 조회 315
10년 전 조회 325
10년 전 조회 437
10년 전 조회 356
10년 전 조회 283
10년 전 조회 330
10년 전 조회 715
10년 전 조회 1,182
10년 전 조회 743
10년 전 조회 534
10년 전 조회 514
10년 전 조회 396
10년 전 조회 372
10년 전 조회 381
10년 전 조회 350
10년 전 조회 375
10년 전 조회 391
10년 전 조회 521
10년 전 조회 431
10년 전 조회 1,161
10년 전 조회 713
10년 전 조회 440
10년 전 조회 514
10년 전 조회 783
10년 전 조회 494
10년 전 조회 621
10년 전 조회 458
10년 전 조회 572
10년 전 조회 401
10년 전 조회 381
10년 전 조회 385
10년 전 조회 441
10년 전 조회 398
10년 전 조회 458
10년 전 조회 450
10년 전 조회 431
10년 전 조회 596
10년 전 조회 609
10년 전 조회 374
10년 전 조회 672
10년 전 조회 1,022
10년 전 조회 481
10년 전 조회 699
10년 전 조회 705
10년 전 조회 530
10년 전 조회 484
10년 전 조회 448
10년 전 조회 545
10년 전 조회 321
10년 전 조회 352
10년 전 조회 573
10년 전 조회 408
10년 전 조회 372
10년 전 조회 356
10년 전 조회 377
10년 전 조회 376
10년 전 조회 357
10년 전 조회 363
10년 전 조회 394
10년 전 조회 485
10년 전 조회 325
10년 전 조회 364
10년 전 조회 440
10년 전 조회 1,168
10년 전 조회 376
10년 전 조회 372
10년 전 조회 497
10년 전 조회 375
10년 전 조회 548
10년 전 조회 490
10년 전 조회 375
10년 전 조회 371
10년 전 조회 425
10년 전 조회 423
10년 전 조회 311
10년 전 조회 315
10년 전 조회 270
10년 전 조회 323
10년 전 조회 722
10년 전 조회 339
10년 전 조회 443
🐛 버그신고