public function onBeforeHostDelete(ModelEvent $event) { /* @var $host Host */ $host = $event->getModel(); /* @var $serviceRepository ServiceRepository */ $serviceRepository = $this->get('devture_nagios.service.repository'); foreach ($serviceRepository->findByHost($host) as $service) { $serviceRepository->delete($service); } }
public function onBeforeTimePeriodDelete(ModelEvent $event) { /* @var $timePeriod TimePeriod */ $timePeriod = $event->getModel(); /* @var $contactRepository ContactRepository */ $contactRepository = $this->get('devture_nagios.contact.repository'); foreach ($contactRepository->findByTimePeriod($timePeriod) as $contact) { $contactRepository->delete($contact); } }
public function onBeforeContactDelete(ModelEvent $event) { /* @var $contact Contact */ $contact = $event->getModel(); /* @var $serviceRepository ServiceRepository */ $serviceRepository = $this->get('devture_nagios.service.repository'); /* @var $service Service */ foreach ($serviceRepository->findByContact($contact) as $service) { $service->removeContact($contact); $serviceRepository->update($service); } }
public function onBeforeCommandDelete(ModelEvent $event) { /* @var $command Command */ $command = $event->getModel(); $commandType = $command->getType(); if ($commandType === Command::TYPE_SERVICE_CHECK) { /* @var $serviceRepository ServiceRepository */ $serviceRepository = $this->get('devture_nagios.service.repository'); foreach ($serviceRepository->findByCommand($command) as $service) { $serviceRepository->delete($service); } } else { if ($commandType === Command::TYPE_SERVICE_NOTIFICATION) { /* @var $contactRepository ContactRepository */ $contactRepository = $this->get('devture_nagios.contact.repository'); foreach ($contactRepository->findByCommand($command) as $contact) { $contactRepository->delete($contact); } } } }