當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Conversation::fetchNew方法代碼示例

本文整理匯總了PHP中Conversation::fetchNew方法的典型用法代碼示例。如果您正苦於以下問題:PHP Conversation::fetchNew方法的具體用法?PHP Conversation::fetchNew怎麽用?PHP Conversation::fetchNew使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Conversation的用法示例。


在下文中一共展示了Conversation::fetchNew方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createAction

 public function createAction()
 {
     $this->logger->entering();
     $this->logger->info('Creating a new messsage row');
     $messages = new Message();
     $message = $messages->fetchNew();
     $this->logger->info('Setting message from post parameters');
     $messageParams = $messages->filterColumns($this->_getParam('message'));
     $message->setFromArray($messageParams);
     $date = new Zend_Date();
     $message->created_on = $date->get(Zend_Date::ISO_8601);
     $this->logger->info('Creating a new conversation if necessary');
     if (empty($message->conversation_id)) {
         $conversations = new Conversation();
         $conversation = $conversations->fetchNew();
         $conversationParams = $conversations->filterColumns($this->_getParam('conversation'));
         $conversation->setfromArray($conversationParams);
         $conversation->save();
         $message->conversation_id = $conversation->id;
     }
     $this->logger->info('Saving the message');
     $message->save();
     $item = $conversation->findParentItem();
     $owner = $item->findParentUser();
     $asker = $conversation->findParentUser();
     $mail = new Zend_Mail();
     $mail->setFrom('swaplady@example.com', 'Swaplady');
     $mail->addTo($owner->email, $owner->name);
     $mail->setSubject("[Swaplady] New message about {$item->name}");
     $mail->setBodyText($message->body . "\nYou can add to the conversation at http://swaplady.com/conversations/show/{$conversation->id}");
     $mail->send();
     $mail = new Zend_Mail();
     $mail->setFrom('swaplady@example.com', 'Swaplady');
     $mail->addTo($asker->email, $asker->name);
     $mail->setSubject("[Swaplady] New message about {$item->name}");
     $mail->setBodyText($message->body . "\nYou can add to the conversation at http://swaplady.com/conversations/show/{$conversation->id}");
     $mail->send();
     $this->logger->info('Redirecting to show the item of the message');
     $this->_redirect('/conversations/show/' . $message->conversation_id);
 }
開發者ID:josephholsten,項目名稱:swaplady,代碼行數:40,代碼來源:MessageController.php


注:本文中的Conversation::fetchNew方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。