是否可以使用注释来获取特定类型的类/实体常量的ChoiceList
或array
?
我的意思是这样的:
class User{
/**
* @Item(Things,'Label 1')
*/
const SOME_THING1=1;
/**
* @Item(Things,'Label 2')
*/
const SOME_THING2=2;
/**
* @Item(Things,'Label 3')
*/
const SOME_THING3=3;
/**
* @Item(OtherThings,'Label 1')
*/
const SOME_OTHER_THING1=1;
/**
* @Item(OtherThings,'Label 2')
*/
const SOME_OTHER_THING2=2;
...
}
然后:
$builder->add('thing', 'choice', array(
'choice_list' => getChoiceListFromConsts('User','Things')
));
我希望getChoiceListFromConsts('User','Things')
返回类似的内容:
array(
'Label 1' => 1,
'Label 2' => 2,
'Label 3' => 3
);
Symfony2中是否有内置功能,或者是否有提供此类服务的捆绑包?