Symfony1 重写原则枚举默认getter
在基类中: @方法enum getWeightType()返回当前记录的 “重量类型”值 子类:Symfony1 重写原则枚举默认getter,symfony1,enums,doctrine,symfony-1.4,Symfony1,Enums,Doctrine,Symfony 1.4,在基类中: @方法enum getWeightType()返回当前记录的 “重量类型”值 子类: class Exercise extends BaseExercise { public function getWeightType() { $type = parent::getWeightType(); if ($type == 'free') { return 'Wolny'; } else {
class Exercise extends BaseExercise
{
public function getWeightType()
{
$type = parent::getWeightType();
if ($type == 'free') {
return 'Wolny';
} else {
return 'Stacjonarny';
}
}
}
所以基本上我想输出数据库中存储以外的值
在indexSuccess中:
echo $exercise->getWeightType()
我得到一个错误:
致命错误:已达到最大函数嵌套级别“100”,正在中止
有人能给我一些建议吗?重写时需要使用受保护的方法:
$type=$this->\u get('weight\u type')代码>
否则,您将在循环中运行自己,因为它将继续尝试调用您正在重写的访问器方法,而不会访问实际获取内部值的方法