示例#1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->manager = $options['manager'];
     $settings = $this->manager->getSettings();
     foreach ($settings as $section => $setting) {
         $builder->add($section, new Settings($this->manager->get($section)));
     }
 }
示例#2
0
 /**
  * @param string                       $event
  * @param NotificationMessageInterface $message
  */
 public function sendNotification($event, NotificationMessageInterface $message)
 {
     /** @var EntityRepository $repository */
     $repository = $this->entityManager->getRepository('CSBillUserBundle:User');
     $message->setUsers($repository->findAll());
     $notification = new ChainedNotification();
     $settings = $this->settings->get(sprintf('notification.%s', $event));
     if ($settings['email']) {
         $notification->addNotifications($this->factory->createEmailNotification($message));
     }
     if ($settings['hipchat']) {
         $notification->addNotifications($this->factory->createHipchatNotification($message));
     }
     if ($settings['sms']) {
         foreach ($message->getUsers() as $user) {
             if (null === $user->getMobile()) {
                 continue;
             }
             $notification->addNotifications($this->factory->createSmsNotification($user->getMobile(), $message));
         }
     }
     $this->notification->trigger($notification);
 }
示例#3
0
文件: Mailer.php 项目: csbill/csbill
 /**
  * Emails a quote to the customers.
  *
  * @param Quote $quote
  *
  * @return int If the email was successfully sent
  */
 public function sendQuote(Quote $quote)
 {
     $htmlTemplate = $this->getTemplate('CSBillQuoteBundle:Email:quote.html.twig', ['quote' => $quote]);
     $textTemplate = $this->getTemplate('CSBillQuoteBundle:Email:quote.txt.twig', ['quote' => $quote]);
     $subject = $this->getSubject('quote.email_subject', $quote->getId());
     $users = [];
     foreach ($quote->getUsers() as $user) {
         /* @var \CSBill\ClientBundle\Entity\Contact $user */
         $users[(string) $user->getEmail()] = $user->getFirstName() . ' ' . $user->getLastName();
     }
     $event = new QuoteEvent();
     $event->setQuote($quote);
     $bcc = (string) $this->settings->get('quote.bcc_address');
     $sent = $this->sendMessage($subject, $users, $htmlTemplate, $textTemplate, $event, $bcc);
     return $sent;
 }
示例#4
0
文件: Mailer.php 项目: Codixis/CSBill
 /**
  * Emails a quote to the customers.
  *
  * @param Quote $quote
  *
  * @return int If the email was successfully sent
  */
 public function sendQuote(Quote $quote)
 {
     // TODO : this needs to come from settings or somewhere so it can be extended
     $htmlTemplate = $this->getTemplate('CSBillQuoteBundle:Email:quote.html.twig', array('quote' => $quote));
     $textTemplate = $this->getTemplate('CSBillQuoteBundle:Email:quote.txt.twig', array('quote' => $quote));
     $subject = $this->getSubject('quote.email_subject', $quote->getId());
     $users = array();
     foreach ($quote->getUsers() as $user) {
         /* @var \CSBill\ClientBundle\Entity\Contact $user */
         $users[(string) $user->getPrimaryDetail('email')] = $user->getFirstname() . ' ' . $user->getLastname();
     }
     $event = new QuoteEvent();
     $event->setQuote($quote);
     $bcc = (string) $this->settings->get('quote.bcc_address');
     $sent = $this->sendMessage($subject, $users, $htmlTemplate, $textTemplate, $event, $bcc);
     return $sent;
 }
示例#5
0
文件: Factory.php 项目: csbill/csbill
 /**
  * @param NotificationMessageInterface $message
  *
  * @return NotificationInterface
  */
 public function createHipchatNotification(NotificationMessageInterface $message)
 {
     $content = $message->getTextContent($this->templating);
     return new HipChatNotification($content, $this->settings->get('system.general.app_name'), $this->settings->get('hipchat.room_id'), ['hipchat_color' => $this->settings->get('hipchat.message_color'), 'hipchat_notify' => (string) $this->settings->get('hipchat.notify')]);
 }