예제 #1
0
 /**
  * Write a notification
  *
  * @param           $message    Message of the notification
  * @param           $type       Optional $type to ID the source of the notification
  * @param bool|true $isRead     Add unread indicator
  * @param           $header     Header for message
  * @param string    $iconClass  Font Awesome CSS class for the icon (e.g. fa-eye)
  * @param \DateTime $datetime   Date the item was created
  * @param User|null $user       User object; defaults to current user
  */
 public function addNotification($message, $type = null, $isRead = true, $header = null, $iconClass = null, \DateTime $datetime = null, User $user = null)
 {
     if ($user === null) {
         $user = $this->factory->getUser();
     }
     if ($user === null || !$user->getId()) {
         //ensure notifications aren't written for non users
         return;
     }
     $notification = new Notification();
     $notification->setType($type);
     $notification->setIsRead($isRead);
     $notification->setHeader($header);
     $notification->setMessage($message);
     $notification->setIconClass($iconClass);
     $notification->setUser($user);
     if ($datetime == null) {
         $datetime = new \DateTime();
     }
     $notification->setDateAdded($datetime);
     $this->saveEntity($notification);
 }
 /**
  * {@inheritDoc}
  */
 public function setHeader($header)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHeader', array($header));
     return parent::setHeader($header);
 }