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