我有一个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模式还是什么?
答案 0 :(得分:1)
它就像典型的分层架构中的基本应用程序服务。
应用程序服务:由外部使用者用于与您的系统通信(想想Web服务)。如果消费者需要访问CRUD操作,他们就会在这里公开。