コード例 #1
0
 public function testGetRandomNotification()
 {
     $result = $this->beaconNotificationDao->getRandomNotification();
     $notification = new BeaconNotification();
     $notification->fromArray($result);
     $this->assertTrue($notification instanceof BeaconNotification);
     $this->assertTrue(!is_null($notification->getDefinition()));
 }
コード例 #2
0
 public function execute($request)
 {
     $this->notificationEnabled = false;
     $count = 0;
     $notification = null;
     do {
         if (isset($notification) && $notification) {
             $this->getBeaconNotificationService()->deleteNotificationByName($notification->getName());
         }
         $notificationArr = $this->getBeaconNotificationService()->getRandomNotification();
         if (!$notificationArr) {
             break;
         }
         $notification = new BeaconNotification();
         $notification->fromArray($notificationArr);
     } while (time() > strtotime($notification->getExpiryDate()) && ++$count < self::MAX_TRIES);
     if (isset($notification) && $count < self::MAX_TRIES) {
         $this->notificationEnabled = true;
         $notificationXML = new SimpleXMLElement($notification->getDefinition());
         $this->notificationHeader = $this->getBeaconNotificationService()->sanitizeNotificationSection(trim($notificationXML->content->header . ""));
         $this->notificationBody = $this->getBeaconNotificationService()->sanitizeNotificationSection(trim($notificationXML->content->body . ""));
     }
 }