示例#1
0
 public function notifyUpdateFailure(Package $package, \Exception $e, $details = null)
 {
     if (!$package->isUpdateFailureNotified()) {
         $recipients = array();
         foreach ($package->getMaintainers() as $maintainer) {
             if ($maintainer->isNotifiableForFailures()) {
                 $recipients[$maintainer->getEmail()] = $maintainer->getUsername();
             }
         }
         if ($recipients) {
             $body = $this->twig->render('PackagistWebBundle:Email:update_failed.txt.twig', array('package' => $package, 'exception' => get_class($e), 'exceptionMessage' => $e->getMessage(), 'details' => $details));
             $message = \Swift_Message::newInstance()->setSubject($package->getName() . ' failed to update, invalid composer.json data')->setFrom($this->options['from'], $this->options['fromName'])->setTo($recipients)->setBody($body);
             try {
                 $this->mailer->send($message);
             } catch (\Swift_TransportException $e) {
                 $this->logger->error('[' . get_class($e) . '] ' . $e->getMessage());
                 return false;
             }
         }
         $package->setUpdateFailureNotified(true);
         $this->em->flush();
     }
     return true;
 }