我读到一个好的做法有实体灯,只有 getter 和 setter。但是,例如,我有一些具有某些逻辑的自定义方法。
public function calculatePrice(){
/*
Here I have to do many math operations
including access to other repositories to get
specific data (taxes, comissions, ect) from others entities
*/
}
将这种“更复杂的方法”放在哪里做:
//in controller
$product->calculatePrice()
//in twig templates
{{ product.calculatePrice }}