/**
  * persist
  *
  * @param ThreadInterface $thread
  * @return ThreadInterface
  */
 public function persist(ThreadInterface $thread)
 {
     $data = new ArrayObject($thread->toArray());
     if ($thread->getThreadId() > 0) {
         $this->getTableGateway()->update((array) $data, array($this->threadIDField => $thread->getThreadId()));
     } else {
         $this->getTableGateway()->insert((array) $data);
         $threadId = $this->getTableGateway()->getAdapter()->getDriver()->getConnection()->getLastGeneratedId();
         $thread->setThreadId($threadId);
     }
     return $thread;
 }
Example #2
0
 /**
  * getMessagesByThread
  *
  * @param ThreadInterface $thread
  * @param int $limit
  * @param int $offset
  * @return array
  */
 public function getMessagesByThread(ThreadInterface $thread, $limit = 25, $offset = 0)
 {
     return $this->messageMapper->getMessagesByThread($thread->getThreadId(), $limit, $offset);
 }