示例#1
0
 /**
  * createThread
  *
  * @param ThreadInterface $thread
  * @return ThreadInterface
  */
 public function createThread(ThreadInterface $thread, MessageInterface $message)
 {
     $message = $this->messageMapper->persist($message);
     $thread->setOriginalMessage($message);
     $thread = $this->threadMapper->persist($thread);
     $this->events()->trigger(__FUNCTION__, $this, array('thread' => $thread));
     return $thread;
 }
示例#2
0
 /**
  * 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;
 }