public function notify($id, $data) { $notification = $this->storage->findOneByIdAndCode($id, $this->code); if ($notification === null) { $notification = new Notification(); $notification->setId($id)->setCode($this->code); } else { $notification->setSentAt(null)->setSentCount(0); } $notification->setData($data); $this->storage->persist($notification); return $notification; }
/** * @param string $id * @param string $data * @return Notification */ private function createNotification($id, $data) { $notification = new Notification(); $notification->setId($id)->setData($data)->setSentAt(new \DateTime())->setSentCount(0); return $notification; }