【发布时间】:2014-11-27 17:42:39
【问题描述】:
我有一个 DashboardService 类(在 symfony2 中定义为服务),我用它调用一些方法从一些存储库中获取结果(只是查询)并显示数据。
class DashboardService {
/**
* @var EntityManager
*/
private $em;
public function __construct(EntityManager $em) {
$this->em = $em;
}
public function getTotalActiveCampaignsByMonth($month) {
$campaigns = $this->em->getRepository("WMAdminBundle:Campaign")->countAllActiveCampaignsByMonth($month);
return $campaigns;
}
public function getTotalContactsByMonth($month) {
$contacts = $this->em->getRepository("WMAdminBundle:Contact")->countAllContactsSentByMonth($month);
return $contacts;
}
public function getTotalCAByMonth($month) {
$ca = $this->em->getRepository("WMAdminBundle:ContactCampaign")->getAllCAByMonth($month);
return $ca;
}
public function getTop10RentabilityCampaigns() {
$campaigns = $this->em->getRepository("WMAdminBundle:Campaign")->findAllTop10Rentability();
return $campaigns;
}
public function getTop10ContactCampaigns() {
$campaigns = $this->em->getRepository("WMAdminBundle:Campaign")->findAllTop10Contacts();
return $campaigns;
}
}
这个类是 OOP 模式还是什么?
【问题讨论】:
标签: php oop symfony doctrine repository-pattern