-
-
Save Nek-/302870658cd26849b33d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ServicePlus\CoreBundle\Service; | |
use Doctrine\ORM\EntityManager; | |
use Doctrine\ORM\EntityNotFoundException; | |
use ServicePlus\CoreBundle\Entity\Company; | |
use ServicePlus\CoreBundle\Entity\Device; | |
use ServicePlus\CoreBundle\Entity\Report; | |
use Symfony\Component\EventDispatcher\EventDispatcher; | |
use Symfony\Component\EventDispatcher\GenericEvent; | |
class ReportService | |
{ | |
/** @var \Doctrine\ORM\EntityManager */ | |
private $em; | |
/** @var \Symfony\Component\EventDispatcher\EventDispatcher */ | |
private $dispatcher; | |
/** @var \Doctrine\ORM\EntityRepository */ | |
private $repo; | |
public function __construct(EntityManager $em, EventDispatcher $dispatcher) | |
{ | |
$this->em = $em; | |
$this->repo = $this->em->getRepository('ServicePlusCoreBundle:Report'); | |
$this->dispatcher = $dispatcher; | |
} | |
/** | |
* @param array $data | |
*/ | |
public function generateFromForm(array $data) | |
{ | |
/** @var Company $company */ | |
foreach ($data['companies'] as $company) { | |
$report = $this->findReport($company, $data); | |
if ($report) { | |
if ($data['force_generate']) { | |
$this->removeReport($report); | |
} else { | |
continue; | |
} | |
} | |
$this->generateForCompany($company, $data); | |
$this->dispatcher->dispatch('serviceplus.report.created', new GenericEvent(new Company())); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
serviceplus.mailer: | |
class: ServicePlus\CoreBundle\Listener\MailerListener | |
arguments: | |
- @mailer | |
- @twig | |
- @router | |
tags: | |
- { name: kernel.event_listener, event: serviceplus.manager.created, method: managerCreatedEmail } | |
- { name: kernel.event_listener, event: serviceplus.signup.account_created, method: onAccountCreated } | |
- { name: kernel.event_listener, event: serviceplus.signup.account_activated, method: onAccountActivated } | |
- { name: kernel.event_listener, event: serviceplus.device.transfer, method: onCertificateTransfer } | |
- { name: kernel.event_listener, event: serviceplus.certificate.purchased, method: onCertificatePurchased } | |
- { name: kernel.event_listener, event: serviceplus.certificate.created, method: onCertificatePurchased } | |
- { name: kernel.event_listener, event: serviceplus.report.created, method: onReportCreated } | |
serviceplus.service.report: | |
class: ServicePlus\CoreBundle\Service\ReportService | |
arguments: | |
- @doctrine.orm.entity_manager | |
- @event_dispatcher |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment