Benjamin B.
Benjamin B.

Reputation: 483

OOP Pattern with methods calling Repositories

I have a class DashboardService (defined as a service in symfony2), i use it to call some methods to get results (just queries) from some repositories and display data.

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;
}

}

Is this class an OOP pattern or something ?

Upvotes: 0

Views: 117

Answers (1)

Hadi Ahmadi
Hadi Ahmadi

Reputation: 348

it's like a basic application service in a typical layered architecture.

Application Services : Used by external consumers to talk to your system (think Web Services). If consumers need access to CRUD operations, they would be exposed here.

Upvotes: 2

Related Questions