コード例 #1
0
 public function storeAction(NotificationConfiguration $notificationConfiguration, Request $request)
 {
     $this->assertUserRights(UserRole::ROLE_ADMIN);
     $notificationConfiguration->setNotificationCondition($request->get('condition'));
     if ($request->get('notify_ack') === "true") {
         $notificationConfiguration->setNotifyAcknowledge(true);
     } else {
         $notificationConfiguration->setNotifyAcknowledge(false);
     }
     if ($request->get('notify_all') === "true") {
         $notificationConfiguration->setNotifyAll(true);
         $notificationConfiguration->clearConnectedTools();
     } else {
         $notificationConfiguration->setNotifyAll(false);
         $notificationConfiguration->clearConnectedTools();
         $tools = $request->get('tools');
         if (!is_null($tools)) {
             foreach ($tools as $toolId => $value) {
                 $tool = $this->getDoctrine()->getRepository('KoalamonIncidentDashboardBundle:Tool')->find((int) $toolId);
                 /** @var Tool $tool */
                 if ($tool->getProject() == $this->getProject()) {
                     $notificationConfiguration->addConnectedTool($tool);
                 }
             }
         }
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($notificationConfiguration);
     $em->flush();
     return $this->redirectToRoute('koalamon_notification_alerts_home');
 }
コード例 #2
0
 public function sendNotification(NotificationConfiguration $config, Event $event, Event $lastEvent = null)
 {
     $container = new VariableContainer();
     $container->addVariable('event.status', $event->getStatus());
     $container->addVariable('event.message', $event->getMessage());
     $container->addVariable('event.url', $this->router->generate("bauer_incident_dashboard_core_homepage", array('project' => $event->getEventIdentifier()->getProject()->getIdentifier()), true));
     if ($lastEvent) {
         $container->addVariable('lastevent.message', $lastEvent->getMessage());
         $container->addVariable('lastevent.status', $lastEvent->getStatus());
     }
     $container->addVariable('system.name', $event->getSystem());
     $container->addVariable('tool.name', $event->getEventIdentifier()->getTool()->getName());
     $sender = SenderFactory::getSender($config->getSenderType());
     if ($sender instanceof ContainerAwareInterface) {
         $sender->setContainer($this->container);
     }
     $sender->init($this->router, $config->getOptions(), $container);
     $sender->send($event);
 }
コード例 #3
0
 public function storeAction(Request $request)
 {
     $this->assertUserRights(UserRole::ROLE_ADMIN);
     $em = $this->getDoctrine()->getManager();
     if ($request->get('configurationId') > 0) {
         $configuration = $this->getDoctrine()->getRepository('KoalamonNotificationBundle:NotificationConfiguration')->find($request->get('configurationId'));
     } else {
         $configuration = new NotificationConfiguration();
         $configuration->setNotifyAll(false);
     }
     $configuration->setOptions($request->get('options'));
     $configuration->setSenderType($request->get('senderIdentifier'));
     $configuration->setProject($this->getProject());
     $configuration->setName($request->get('name'));
     $em->persist($configuration);
     $em->flush();
     return $this->redirectToRoute('koalamon_notification_home');
 }