当前位置: 首页>>代码示例>>PHP>>正文


PHP Conversation::setScenario方法代码示例

本文整理汇总了PHP中Conversation::setScenario方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::setScenario方法的具体用法?PHP Conversation::setScenario怎么用?PHP Conversation::setScenario使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conversation的用法示例。


在下文中一共展示了Conversation::setScenario方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeAll

 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Account")');
     $conversations = array();
     foreach (self::getConversationData() as $randomConversationData) {
         $postData = array();
         $conversation = new Conversation();
         $conversation->setScenario('importModel');
         $conversation->owner = $demoDataHelper->getRandomByModelName('User');
         $conversation->createdByUser = $conversation->owner;
         $conversation->conversationItems->add($demoDataHelper->getRandomByModelName('Account'));
         $conversation->subject = $randomConversationData['subject'];
         $conversation->description = $randomConversationData['description'];
         //Add some comments
         foreach ($randomConversationData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $conversation->comments->add($comment);
             self::addItemIdToPostData($postData, $comment->createdByUser->getClassId('Item'));
         }
         //Add Super user
         $comment = new Comment();
         $comment->description = 'Great idea guys. Keep it coming.';
         $conversation->comments->add($comment);
         self::addItemIdToPostData($postData, Yii::app()->user->userModel->getClassId('Item'));
         $saved = $conversation->save();
         assert('$saved');
         //any user who has made a comment should be added as a participant and resolve permissions
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
         ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$saved');
         $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$success');
         $conversations[] = $conversation->id;
     }
     $demoDataHelper->setRangeByModelName('Conversation', $conversations[0], $conversations[count($conversations) - 1]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:46,代码来源:ConversationsDemoDataMaker.php


注:本文中的Conversation::setScenario方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。