本文整理汇总了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]);
}