public function resolveNotificationMessages($messages) { $idArray = array(); $beaconNotificationService = new BeaconNotificationService(); foreach ($messages as $message) { try { $messageBody = new SimpleXMLElement($message['definition']); $name = $message['name']; $idArray[] = $message['id']; $notification = new BeaconNotification(); if ($message['operation'] == 'DELETE') { $result = $beaconNotificationService->deleteNotificationByName($name); continue; } else { if ($message['operation'] == 'UPDATE') { $notification = $beaconNotificationService->getNotificationByName($name); if ($notification == null || !$notification) { $notification = new BeaconNotification(); } } } $notification->setName($name); $notification->setDefinition($message['definition']); $period = trim($messageBody->settings->period . ""); $expiry = time() + (int) $period; $time = new DateTime(); $time->setTimestamp($expiry); $notification->setExpiryDate($time->format('Y-m-d H:i:s')); $notification->save(); } catch (Exception $exc) { echo $exc->getTraceAsString(); } } return $idArray; }