/**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     if (!$this->hasSmtpOptions($config)) {
         $transport = new Sendmail();
     } else {
         $transport = new Smtp(new SmtpOptions($config['mail']['smtpOptions']));
     }
     if (array_key_exists('mail', $config) && array_key_exists('smtpOptions', $config['mail'])) {
         unset($config['mail']['smtpOptions']);
     }
     $configuration = new Configuration($config['mail']);
     $mailService = new MailService($transport, $configuration);
     $errorEventManager = new ErrorEventManager();
     $mailService->setEventManager($errorEventManager);
     $service = new ErrorService(new \BitWeb\ErrorReporting\Configuration($serviceLocator->get('Config')['error_reporting']));
     $service->setEventManager($errorEventManager);
     $service->setEvent(MailService::EVENT_SEND_MAIL);
     return $service;
 }
Exemplo n.º 2
0
 public function testRestoreDefaultErrorHandling()
 {
     $service = new ErrorService($this->configuration);
     $this->assertTrue($service->restoreDefaultErrorHandling());
 }